def test_reraise_exception_in_step(self): crash_at_step = 3 constructor = functools.partial(MockEnvironmentCrashInStep, crash_at_step) env = ProcessEnvironment(constructor) env.start() env.reset() action_spec = env.action_spec() env.step(action_spec.sample()) env.step(action_spec.sample()) with self.assertRaises(Exception): env.step(action_spec.sample())
def test_close_no_hang_after_step(self): constructor = functools.partial( RandomAlfEnvironment, ts.TensorSpec((3, 3), torch.float32), ts.BoundedTensorSpec([1], torch.float32, minimum=-1.0, maximum=1.0), episode_end_probability=0, min_duration=5, max_duration=5) env = ProcessEnvironment(constructor) env.start() action_spec = env.action_spec() env.reset() env.step(action_spec.sample()) env.step(action_spec.sample()) env.close()
def test_reraise_exception_in_reset(self): constructor = MockEnvironmentCrashInReset env = ProcessEnvironment(constructor) env.start() with self.assertRaises(Exception): env.reset()