File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -281,6 +281,16 @@ def eval(
281281 ready_env_id = ready_env_id .union (set (list (new_available_env_id )[:remain_episode ]))
282282 remain_episode -= min (len (new_available_env_id ), remain_episode )
283283
284+ # In a parallel evaluation setting, it's possible for all active environments to finish their
285+ # episodes simultaneously. This can leave `ready_env_id` temporarily empty while the environments
286+ # are being reset by the manager.
287+ # To prevent processing an empty batch, which would cause an IndexError or other errors downstream,
288+ # we check if `ready_env_id` is empty. If so, we sleep briefly to prevent a busy-wait,
289+ # and `continue` to the next loop iteration to wait for newly reset environments to become available.
290+ if not ready_env_id :
291+ time .sleep (0.01 )
292+ continue
293+
284294 stack_obs = {env_id : game_segments [env_id ].get_obs () for env_id in ready_env_id }
285295 stack_obs = list (stack_obs .values ())
286296
You can’t perform that action at this time.
0 commit comments