Skip to content

Commit

Permalink
adds explicit killing of workers
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiran Karra authored and Kiran Karra committed Aug 20, 2020
1 parent e7fd252 commit 64833c6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions torch_ac/utils/penv.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def worker(conn, env):
elif cmd == "reset":
obs = env.reset()
conn.send(obs)
elif cmd == "kill":
return
else:
raise NotImplementedError

Expand All @@ -34,6 +36,10 @@ def __init__(self, envs):
p.start()
remote.close()

def __del__(self):
for local in self.locals:
local.send(("kill", None))

def reset(self):
for local in self.locals:
local.send(("reset", None))
Expand Down

0 comments on commit 64833c6

Please sign in to comment.