mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-09-05 20:30:42 +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:
|
||||
pass
|
||||
|
||||
# finally, check that the allows calling `close()` even if the environment was already closed
|
||||
env.close()
|
||||
try:
|
||||
env.close()
|
||||
except Exception as e:
|
||||
warnings.warn(f"We recommend to allow calling `close()` even if the environment was already closed.")
|
||||
# Finally, check that the allows calling `close()` even if the environment was already closed
|
||||
if env.spec is not None:
|
||||
new_env = env.spec.make()
|
||||
new_env.close()
|
||||
try:
|
||||
new_env.close()
|
||||
except Exception as e:
|
||||
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