コード例 #1
0
 def test_wait(self):
     p = DummyProcess.new()
     self.assertTrue(p.wait(timeout=2.),
                     "Not running process didn't return from wait")
     self.executor.play(p)
     self.assertTrue(p.wait(timeout=2.),
                     "Process failed to return from wait when done")
コード例 #2
0
 def test_interrupt(self):
     p = DummyProcess.new()
     w = WaitOnState(p, ProcessState.STOPPED)
     self.assertFalse(w.wait(0.2))
     w.interrupt()
     self.manager.start(p)
     self.assertFalse(w.wait(0.2))
コード例 #3
0
 def test_interrupt_not_waiting(self):
     """
     If you interrupt when it's not waiting then nothing happens.
     """
     p = DummyProcess.new()
     waiton = WaitOnProcessState(p, ProcessState.STOPPED)
     waiton.interrupt()
コード例 #4
0
 def test_pause_play(self):
     """
     Pausing a process that is not playing should have no effect and next 
     time it is played it should continue normally.
     """
     p = DummyProcess.new()
     self.assertTrue(p.pause(timeout=1.))
     p.play()
     self.assertEqual(p.state, ProcessState.STOPPED)
コード例 #5
0
    def test_play(self):
        p = DummyProcess.new()
        self.assertFalse(p.has_finished())

        fut = self.executor.play(p)
        self.assertTrue(fut.wait(timeout=1.))

        self.assertTrue(p.has_terminated())
        self.assertTrue(p.has_finished())
コード例 #6
0
ファイル: test_process.py プロジェクト: DropD/plumpy
    def test_abort(self):
        # Abort a process before it gets started, this will get ignored and the
        # process will run normally
        proc = DummyProcess.new()
        proc.abort()
        proc.play()

        self.assertFalse(proc.has_aborted())
        self.assertEqual(proc.state, ProcessState.STOPPED)
コード例 #7
0
ファイル: test_event.py プロジェクト: sphuber/plumpy
    def test_normal_process(self):
        saver = _EventSaver()
        self.emitter.start_listening(saver.event_ocurred, "process.*")

        p = DummyProcess.new()
        preamble = "process.{}.".format(p.pid)
        p.play()

        self.assertEqual(saver.events, [preamble + 'finished', preamble + 'stopped'])
コード例 #8
0
    def test_state_messages(self):
        tp = PythonThreadPoolExecutor(max_workers=1)
        for state in (ProcessState.RUNNING, ProcessState.STOPPED):
            p = DummyProcess.new()
            waiton = WaitOnProcessState(p, state)
            future = tp.submit(waiton.wait)
            while not future.running():
                pass

            p.play()
            self.assertTrue(future.result(timeout=2.))
コード例 #9
0
    def test_interrupt(self):
        tp = PythonThreadPoolExecutor(max_workers=1)

        p = DummyProcess.new()
        waiton = WaitOnProcessState(p, ProcessState.STOPPED)
        future = tp.submit(waiton.wait)
        while not future.running():
            pass

        with self.assertRaises(Interrupted):
            waiton.interrupt()
            future.result(timeout=2.)
コード例 #10
0
ファイル: test_event.py プロジェクト: sphuber/plumpy
    def test_finished_stopped(self):
        for event in ("finished", "stopped"):
            tp = ThreadPoolExecutor(max_workers=1)
            p = DummyProcess.new()

            w = WaitOnProcessEvent(self.emitter, p.pid, event)
            future = tp.submit(w.wait)
            while not future.running():
                pass

            p.play()
            self.assertTrue(future.result(timeout=2.))
コード例 #11
0
    def test_spec(self):
        """
        Check that the references to specs are doing the right thing...
        """
        dp = DummyProcess.new()
        self.assertIsNot(DummyProcess.spec(), Process.spec())
        self.assertIs(dp.spec(), DummyProcess.spec())

        class Proc(DummyProcess):
            pass

        self.assertIsNot(Proc.spec(), Process.spec())
        self.assertIsNot(Proc.spec(), DummyProcess.spec())
        p = Proc.new()
        self.assertIs(p.spec(), Proc.spec())
コード例 #12
0
 def test_abort(self):
     proc = DummyProcess.new()
     proc.abort()
     self.assertTrue(proc.has_aborted())
     self.assertEqual(proc.state, ProcessState.STOPPED)
コード例 #13
0
ファイル: test_process_manager.py プロジェクト: DropD/plumpy
 def test_start(self):
     p = DummyProcess.new()
     self.assertFalse(p.has_finished())
     self.manager.start(p)
     wait_until_stopped(p, 1)
     self.assertTrue(p.has_finished())
コード例 #14
0
ファイル: test_process_manager.py プロジェクト: DropD/plumpy
 def test_future_pid(self):
     p = DummyProcess.new()
     future = self.manager.start(p)
     self.assertEqual(future.pid, p.pid)
コード例 #15
0
 def test_already_in_state(self):
     p = DummyProcess.new()
     self.assertTrue(WaitOnProcessState(p, ProcessState.CREATED).wait(timeout=2.))
コード例 #16
0
 def test_future_pid(self):
     p = DummyProcess.new()
     future = self.executor.play(p)
     self.assertEqual(future.pid, p.pid)