예제 #1
0
 def test_on_accepted_terminates(self):
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     pool = Mock()
     tw.terminate(pool, signal="KILL")
     self.assertFalse(pool.terminate_job.call_count)
     tw.on_accepted(pid=314, time_accepted=time.time())
     pool.terminate_job.assert_called_with(314, "KILL")
예제 #2
0
 def test_on_accepted_terminates(self):
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     pool = Mock()
     tw.terminate(pool, signal="KILL")
     self.assertFalse(pool.terminate_job.call_count)
     tw.on_accepted(pid=314, time_accepted=time.time())
     pool.terminate_job.assert_called_with(314, "KILL")
예제 #3
0
 def test_terminate__task_started(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     tw.time_start = time.time()
     tw.worker_pid = 313
     tw.terminate(pool, signal="KILL")
     pool.terminate_job.assert_called_with(tw.worker_pid, "KILL")
예제 #4
0
 def test_terminate__task_started(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     tw.time_start = time.time()
     tw.worker_pid = 313
     tw.terminate(pool, signal="KILL")
     pool.terminate_job.assert_called_with(tw.worker_pid, "KILL")
예제 #5
0
 def test_terminate__task_reserved(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     tw.time_start = None
     tw.terminate(pool, signal="KILL")
     self.assertFalse(pool.terminate_job.call_count)
     self.assertTupleEqual(tw._terminate_on_ack, (True, pool, "KILL"))
     tw.terminate(pool, signal="KILL")
예제 #6
0
 def test_terminate__task_reserved(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     tw.time_start = None
     tw.terminate(pool, signal="KILL")
     self.assertFalse(pool.terminate_job.call_count)
     self.assertTupleEqual(tw._terminate_on_ack, (True, pool, "KILL"))
     tw.terminate(pool, signal="KILL")
예제 #7
0
 def test_terminate__task_reserved(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}, app=self.app)
     tw.time_start = None
     tw.terminate(pool, signal='KILL')
     self.assertFalse(pool.terminate_job.called)
     self.assertTupleEqual(tw._terminate_on_ack, (pool, 'KILL'))
     tw.terminate(pool, signal='KILL')
예제 #8
0
 def test_terminate__task_reserved(self):
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'})
     tw.time_start = None
     tw.terminate(pool, signal='KILL')
     self.assertFalse(pool.terminate_job.called)
     self.assertTupleEqual(tw._terminate_on_ack, (pool, 'KILL'))
     tw.terminate(pool, signal='KILL')
예제 #9
0
 def test_terminate__task_reserved(self):
     pool = Mock()
     job = TaskRequest(self.mytask.name, uuid(), [1], {"f": "x"}, app=self.app)
     job.time_start = None
     job.terminate(pool, signal="KILL")
     self.assertFalse(pool.terminate_job.called)
     self.assertTupleEqual(job._terminate_on_ack, (pool, "KILL"))
     job.terminate(pool, signal="KILL")
예제 #10
0
 def test_on_accepted_terminates(self):
     signum = signal.SIGKILL
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     with assert_signal_called(task_revoked, sender=tw.task, terminated=True, expired=False, signum=signum):
         tw.terminate(pool, signal="KILL")
         self.assertFalse(pool.terminate_job.call_count)
         tw.on_accepted(pid=314, time_accepted=time.time())
         pool.terminate_job.assert_called_with(314, signum)
예제 #11
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGKILL
     tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"})
     with assert_signal_called(task_revoked, sender=tw.task, terminated=True, expired=False, signum=signum):
         tw.time_start = time.time()
         tw.worker_pid = 313
         tw.terminate(pool, signal="KILL")
         pool.terminate_job.assert_called_with(tw.worker_pid, signum)
예제 #12
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGKILL
     job = TaskRequest(self.mytask.name, uuid(), [1], {"f": "x"}, app=self.app)
     with assert_signal_called(
         task_revoked, sender=job.task, request=job, terminated=True, expired=False, signum=signum
     ):
         job.time_start = time.time()
         job.worker_pid = 313
         job.terminate(pool, signal="KILL")
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
예제 #13
0
 def test_on_accepted_terminates(self):
     signum = signal.SIGKILL
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'})
     with assert_signal_called(task_revoked, sender=tw.task,
                               terminated=True,
                               expired=False,
                               signum=signum):
         tw.terminate(pool, signal='KILL')
         self.assertFalse(pool.terminate_job.call_count)
         tw.on_accepted(pid=314, time_accepted=time.time())
         pool.terminate_job.assert_called_with(314, signum)
예제 #14
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGKILL
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'})
     with assert_signal_called(task_revoked, sender=tw.task,
                               terminated=True,
                               expired=False,
                               signum=signum):
         tw.time_start = time.time()
         tw.worker_pid = 313
         tw.terminate(pool, signal='KILL')
         pool.terminate_job.assert_called_with(tw.worker_pid, signum)
예제 #15
0
 def test_on_accepted_terminates(self):
     signum = signal.SIGKILL
     pool = Mock()
     job = TaskRequest(
         self.mytask.name, uuid(), [1], {'f': 'x'}, app=self.app,
     )
     with assert_signal_called(
             task_revoked, sender=job.task,
             terminated=True, expired=False, signum=signum):
         job.terminate(pool, signal='KILL')
         self.assertFalse(pool.terminate_job.call_count)
         job.on_accepted(pid=314, time_accepted=time.time())
         pool.terminate_job.assert_called_with(314, signum)