NVlabs / GA3C

Hybrid CPU/GPU implementation of the A3C algorithm for deep reinforcement learning.
BSD 3-Clause "New" or "Revised" License
652 stars 195 forks source link

Fix for hanging on quit (fixes issues #4 and #21 ) #23

Open Miffyli opened 7 years ago

Miffyli commented 7 years ago

Processes/threads got stuck in queue.get() operations which normally block indefinitely. This commit adds timeouts with required checks to quit when exit_flags are set to True. Added exit_flag for ProcessStats. Added long timeout for receiving prediction in ProcessAgent. I don't see why this hangs at times but during tests there were rare cases where this part hanged.

The code "overshoots" the number of episodes defined in Config before closing. With EPISODES=10 my run reaches ~60 episodes before closing.

Edit: Actually this could be made better by using multiprocessing.Queue.close. It would still require try-excepts but would avoid using get every 0.001 seconds.