def test_step_out_of_order_async_vector_env(shared_memory): env_fns = [make_env("CubeCrash-v0", i) for i in range(4)] with pytest.raises(NoAsyncCallError): try: env = AsyncVectorEnv(env_fns, shared_memory=shared_memory) actions = env.action_space.sample() observations = env.reset() observations, rewards, dones, infos = env.step_wait() except AlreadyPendingCallError as exception: assert exception.name == "step" raise finally: env.close(terminate=True) with pytest.raises(AlreadyPendingCallError): try: env = AsyncVectorEnv(env_fns, shared_memory=shared_memory) actions = env.action_space.sample() env.reset_async() env.step_async(actions) except AlreadyPendingCallError as exception: assert exception.name == "reset" raise finally: env.close(terminate=True)
def test_step_timeout_async_vector_env(shared_memory): env_fns = [make_slow_env(0.0, i) for i in range(4)] with pytest.raises(TimeoutError): try: env = AsyncVectorEnv(env_fns, shared_memory=shared_memory) observations = env.reset() env.step_async([0.1, 0.1, 0.3, 0.1]) observations, rewards, dones, _ = env.step_wait(timeout=0.1) finally: env.close(terminate=True)