mirror of
https://github.com/saymrwulf/stable-baselines3.git
synced 2026-07-30 20:18:15 +00:00
check double close
This commit is contained in:
parent
8416f03c14
commit
abc994513a
1 changed files with 7 additions and 1 deletions
|
|
@ -369,7 +369,6 @@ def _check_render(env: gym.Env, warn: bool = False) -> None: # pragma: no cover
|
|||
# Only check currrent render mode
|
||||
if env.render_mode:
|
||||
env.render()
|
||||
env.close()
|
||||
|
||||
|
||||
def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -> None:
|
||||
|
|
@ -448,3 +447,10 @@ def check_env(env: gym.Env, warn: bool = True, skip_render_check: bool = True) -
|
|||
_check_nan(env)
|
||||
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.")
|
||||
|
|
|
|||
Loading…
Reference in a new issue