minerllabs / minerl

MineRL Competition for Sample Efficient Reinforcement Learning - Python Package
http://minerl.io/docs/
Other
711 stars 153 forks source link

`close` throws an exception on Windows #562

Open Miffyli opened 3 years ago

Miffyli commented 3 years ago

Trying to close MineRL env on Windows leads to (environment is closed properly)

env = gym.make("MineRLTreechop-v0")

obs = env.reset()

env.close()
Failed to delete the temporary minecraft directory.
---------------------------------------------------------------------------
NoSuchProcess                             Traceback (most recent call last)
<ipython-input-4-1baceacf4cb1> in <module>
----> 1 env.close()

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\gym\core.py in close(self)
    241 
    242     def close(self):
--> 243         return self.env.close()
    244 
    245     def seed(self, seed=None):

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\minerl\env\_multiagent.py in close(self)
    671 
    672             if instance.running:
--> 673                 instance.kill()
    674 
    675         self._already_closed = True

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\minerl\env\malmo.py in kill(self)
    619         Kills the process (if it has been launched.)
    620         """
--> 621         self._destruct()
    622         pass
    623 

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\minerl\env\malmo.py in _destruct(self, should_close)
    770 
    771             # Now lets try and end the process if anything is laying around
--> 772             minerl.utils.process_watcher.reap_process_and_children(self.minecraft_process)
    773 
    774             if self in InstanceManager._instance_pool:

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\minerl\utils\process_watcher.py in reap_process_and_children(process, timeout)
     74         )
     75 
---> 76     procs = process.children(recursive=True)[::-1] + [process]
     77     try:
     78         logger.info("About to reap process tree of {}, ".format(get_process_info(process)) +

c:\users\anssi\appdata\local\programs\python\python37\lib\site-packages\psutil\__init__.py in wrapper(self, *args, **kwargs)
    389     def wrapper(self, *args, **kwargs):
    390         if not self.is_running():
--> 391             raise NoSuchProcess(self.pid, self._name)
    392         return fun(self, *args, **kwargs)
    393     return wrapper

NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=15116)