mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-09-06 20:40:56 +00:00
Update env_checker.py to avoid closing after checking
This commit is contained in:
parent
d63a90cca7
commit
30b3a368e3
1 changed files with 10 additions and 6 deletions
|
|
@ -448,9 +448,13 @@ def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# finally, check that the allows calling `close()` even if the environment was already closed
|
# Finally, check that the allows calling `close()` even if the environment was already closed
|
||||||
env.close()
|
if env.spec is not None:
|
||||||
|
new_env = env.spec.make()
|
||||||
|
new_env.close()
|
||||||
try:
|
try:
|
||||||
env.close()
|
new_env.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
warnings.warn(f"We recommend to allow calling `close()` even if the environment was already closed.")
|
logger.warn(
|
||||||
|
f"Calling `env.close()` on the closed environment should be allowed, but it raised an exception: {e}"
|
||||||
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue