Ejemplo n.º 1
0
        def test_restart_async(proc):
            yield test_utils.run_until_waiting(proc)

            # Save the state of the process
            saved_state = plumpy.Bundle(proc)

            # Load a process from the saved state
            loaded_proc = saved_state.unbundle()
            self.assertEqual(loaded_proc.state, ProcessState.WAITING)

            # Now resume it
            self.loop.add_callback(loaded_proc.step_until_terminated)
            loaded_proc.resume()
            yield loaded_proc.future()
            self.assertEqual(loaded_proc.outputs, {'finished': True})
Ejemplo n.º 2
0
        def run_async(proc):
            yield test_utils.run_until_waiting(proc)

            saved_state = plumpy.Bundle(proc)

            result = yield proc.pause()
            self.assertTrue(result)
            self.assertTrue(proc.paused)

            # Kill the process
            proc.kill()

            with self.assertRaises(plumpy.KilledError):
                result = yield proc.future()

            self.assertEqual(proc.state, ProcessState.KILLED)
Ejemplo n.º 3
0
        def run_async(proc):
            yield test_utils.run_until_waiting(proc)

            saved_state = plumpy.Bundle(proc)

            # Run the process to the end
            proc.resume()
            result1 = yield proc.future()

            # Load from saved state and run again
            proc2 = saved_state.unbundle(
                plumpy.LoadSaveContext(loop=self.loop))
            self.loop.add_callback(proc2.step_until_terminated)
            proc2.resume()
            result2 = yield proc2.future()

            # Check results match
            self.assertEqual(result1, result2)
Ejemplo n.º 4
0
        def async_test():
            yield test_utils.run_until_waiting(proc)
            self.assertEqual(proc.state, ProcessState.WAITING)

            result = yield proc.pause()
            self.assertTrue(result)
            self.assertTrue(proc.paused)

            result = proc.play()
            self.assertTrue(result)
            self.assertFalse(proc.paused)

            proc.resume()
            # Wait until the process is terminated
            yield proc.future()

            # Check it's done
            self.assertTrue(proc.done())
            self.assertEqual(proc.state, ProcessState.FINISHED)
Ejemplo n.º 5
0
        def async_test():
            yield test_utils.run_until_waiting(proc)
            self.assertEqual(proc.state, ProcessState.WAITING)

            result = yield proc.pause(PAUSE_STATUS)
            self.assertTrue(result)
            self.assertTrue(proc.paused)
            self.assertEqual(proc.status, PAUSE_STATUS)

            result = proc.play()
            self.assertEqual(proc.status, PLAY_STATUS)
            self.assertIsNone(proc._pre_paused_status)

            proc.resume()
            # Wait until the process is terminated
            yield proc.future()

            # Check it's done
            self.assertTrue(proc.done())
            self.assertEqual(proc.state, ProcessState.FINISHED)
Ejemplo n.º 6
0
    def test_wait_save_continue(self):
        """ Test that process saved while in WAITING state restarts correctly when loaded """
        proc = test_utils.WaitForSignalProcess()
        self.loop.add_callback(proc.step_until_terminated)

        yield test_utils.run_until_waiting(proc)

        saved_state = plumpy.Bundle(proc)

        # Run the process to the end
        proc.resume()
        result1 = yield proc.future()

        # Load from saved state and run again
        proc2 = saved_state.unbundle(plumpy.LoadSaveContext(loop=self.loop))
        self.loop.add_callback(proc2.step_until_terminated)
        proc2.resume()
        result2 = yield proc2.future()

        # Check results match
        self.assertEqual(result1, result2)