Fix close_extras not implemented by default in VectorEnv (#2507)

This commit is contained in:
Tristan Deleu
2021-12-08 19:55:09 -05:00
committed by GitHub
parent c364506710
commit cdb72ea552
2 changed files with 6 additions and 2 deletions

View File

@@ -488,6 +488,10 @@ class AsyncVectorEnv(VectorEnv):
logger.error("Raising the last exception back to the main process.")
raise exctype(value)
def __del__(self):
if not getattr(self, "closed", True):
self.close(terminate=True)
def _worker(index, env_fn, pipe, parent_pipe, shared_memory, error_queue):
assert shared_memory is None

View File

@@ -97,7 +97,7 @@ class VectorEnv(gym.Env):
def close_extras(self, **kwargs):
r"""Clean up the extra resources e.g. beyond what's in this base class."""
raise NotImplementedError()
pass
def close(self, **kwargs):
r"""Close all sub-environments and release resources.
@@ -142,7 +142,7 @@ class VectorEnv(gym.Env):
def __del__(self):
if not getattr(self, "closed", True):
self.close(terminate=True)
self.close()
def __repr__(self):
if self.spec is None: