コード例 #1
0
 def test_revoked(self):
     job = self.xRequest()
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=False, signum=None):
         revoked.add(job.id)
         self.assertTrue(job.revoked())
         self.assertTrue(job._already_revoked)
         self.assertTrue(job.acknowledged)
コード例 #2
0
ファイル: test_request.py プロジェクト: nonoDevil/celery
 def test_revoked(self):
     job = TaskRequest(self.mytask.name, uuid(), [1], {"f": "x"}, app=self.app)
     with assert_signal_called(
         task_revoked, sender=job.task, request=job, terminated=False, expired=False, signum=None
     ):
         revoked.add(job.id)
         self.assertTrue(job.revoked())
         self.assertTrue(job._already_revoked)
         self.assertTrue(job.acknowledged)
コード例 #3
0
ファイル: test_request.py プロジェクト: hanshoudong/celery
 def test_revoked(self):
     job = self.xRequest()
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=False, signum=None):
         revoked.add(job.id)
         self.assertTrue(job.revoked())
         self.assertTrue(job._already_revoked)
         self.assertTrue(job.acknowledged)
コード例 #4
0
ファイル: test_request.py プロジェクト: nonoDevil/celery
 def test_revoked_expires_expired(self):
     job = TaskRequest(
         self.mytask.name, uuid(), [1], {"f": "x"}, app=self.app, expires=datetime.utcnow() - timedelta(days=1)
     )
     with assert_signal_called(
         task_revoked, sender=job.task, request=job, terminated=False, expired=True, signum=None
     ):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(self.mytask.backend.get_status(job.id), states.REVOKED)
コード例 #5
0
ファイル: test_request.py プロジェクト: arunsuresh/celery
 def test_revoked(self):
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'})
     with assert_signal_called(task_revoked, sender=tw.task,
                               terminated=False,
                               expired=False,
                               signum=None):
         revoked.add(tw.id)
         self.assertTrue(tw.revoked())
         self.assertTrue(tw._already_revoked)
         self.assertTrue(tw.acknowledged)
コード例 #6
0
ファイル: test_request.py プロジェクト: nonoDevil/celery
 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, request=job, 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)
コード例 #7
0
ファイル: test_request.py プロジェクト: nonoDevil/celery
 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)
コード例 #8
0
ファイル: test_request.py プロジェクト: hanshoudong/celery
 def test_on_accepted_terminates(self):
     signum = signal.SIGTERM
     pool = Mock()
     job = self.xRequest()
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=True, expired=False, signum=signum):
         job.terminate(pool, signal='TERM')
         self.assertFalse(pool.terminate_job.call_count)
         job.on_accepted(pid=314, time_accepted=monotonic())
         pool.terminate_job.assert_called_with(314, signum)
コード例 #9
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGTERM
     job = self.get_request(self.mytask.s(1, f='x'))
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=True, expired=False, signum=signum):
         job.time_start = monotonic()
         job.worker_pid = 313
         job.terminate(pool, signal='TERM')
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
コード例 #10
0
ファイル: test_request.py プロジェクト: arunsuresh/celery
 def test_revoked_expires_expired(self):
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'},
                      expires=datetime.utcnow() - timedelta(days=1))
     with assert_signal_called(task_revoked, sender=tw.task,
                               terminated=False,
                               expired=True,
                               signum=None):
         tw.revoked()
         self.assertIn(tw.id, revoked)
         self.assertEqual(mytask.backend.get_status(tw.id),
                          states.REVOKED)
コード例 #11
0
ファイル: test_request.py プロジェクト: rhayesbite/celery
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGKILL
     job = Request({"task": self.mytask.name, "id": uuid(), "args": [1], "kwrgs": {"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 = monotonic()
         job.worker_pid = 313
         job.terminate(pool, signal="KILL")
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
コード例 #12
0
ファイル: test_request.py プロジェクト: tsailiming/celery
 def test_revoked(self):
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}, app=self.app)
     with assert_signal_called(task_revoked,
                               sender=tw.task,
                               terminated=False,
                               expired=False,
                               signum=None):
         revoked.add(tw.id)
         self.assertTrue(tw.revoked())
         self.assertTrue(tw._already_revoked)
         self.assertTrue(tw.acknowledged)
コード例 #13
0
ファイル: test_request.py プロジェクト: hanshoudong/celery
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGTERM
     job = self.get_request(self.mytask.s(1, f='x'))
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=True, expired=False, signum=signum):
         job.time_start = monotonic()
         job.worker_pid = 313
         job.terminate(pool, signal='TERM')
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
コード例 #14
0
 def test_on_accepted_terminates(self):
     signum = signal.SIGTERM
     pool = Mock()
     job = self.xRequest()
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=True, expired=False, signum=signum):
         job.terminate(pool, signal='TERM')
         self.assertFalse(pool.terminate_job.call_count)
         job.on_accepted(pid=314, time_accepted=monotonic())
         pool.terminate_job.assert_called_with(314, signum)
コード例 #15
0
ファイル: test_request.py プロジェクト: arunsuresh/celery
 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)
コード例 #16
0
ファイル: test_request.py プロジェクト: arunsuresh/celery
 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)
コード例 #17
0
 def test_revoked_expires_expired(self):
     job = self.get_request(self.mytask.s(1, f='x').set(
         expires=datetime.utcnow() - timedelta(days=1)
     ))
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=True, signum=None):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(
             self.mytask.backend.get_status(job.id),
             states.REVOKED,
         )
コード例 #18
0
ファイル: test_request.py プロジェクト: tsailiming/celery
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGKILL
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}, app=self.app)
     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)
コード例 #19
0
ファイル: test_request.py プロジェクト: hanshoudong/celery
 def test_revoked_expires_expired(self):
     job = self.get_request(self.mytask.s(1, f='x').set(
         expires=datetime.utcnow() - timedelta(days=1)
     ))
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=True, signum=None):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(
             self.mytask.backend.get_status(job.id),
             states.REVOKED,
         )
コード例 #20
0
ファイル: test_request.py プロジェクト: tsailiming/celery
 def test_on_accepted_terminates(self):
     signum = signal.SIGKILL
     pool = Mock()
     tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}, app=self.app)
     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)
コード例 #21
0
ファイル: test_request.py プロジェクト: tsailiming/celery
 def test_revoked_expires_expired(self):
     tw = TaskRequest(mytask.name,
                      uuid(), [1], {'f': 'x'},
                      expires=datetime.utcnow() - timedelta(days=1),
                      app=self.app)
     with assert_signal_called(task_revoked,
                               sender=tw.task,
                               terminated=False,
                               expired=True,
                               signum=None):
         tw.revoked()
         self.assertIn(tw.id, revoked)
         self.assertEqual(mytask.backend.get_status(tw.id), states.REVOKED)
コード例 #22
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGTERM
     job = Request({
         'task': self.mytask.name,
         'id': uuid(),
         'args': [1],
         'kwrgs': {'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 = monotonic()
         job.worker_pid = 313
         job.terminate(pool, signal='TERM')
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
コード例 #23
0
ファイル: test_request.py プロジェクト: daevaorn/celery
    def test_terminate__pool_ref(self):
        pool = Mock()
        signum = signal.SIGTERM
        job = self.get_request(self.mytask.s(1, f='x'))
        job._apply_result = Mock(name='_apply_result')
        with assert_signal_called(
                task_revoked, sender=job.task, request=job,
                terminated=True, expired=False, signum=signum):
            job.time_start = monotonic()
            job.worker_pid = 314
            job.terminate(pool, signal='TERM')
            job._apply_result().terminate.assert_called_with(signum)

            job._apply_result = Mock(name='_apply_result2')
            job._apply_result.return_value = None
            job.terminate(pool, signal='TERM')
コード例 #24
0
 def test_terminate__task_started(self):
     pool = Mock()
     signum = signal.SIGTERM
     job = Request({
         'task': self.mytask.name,
         'id': uuid(),
         'args': [1],
         'kwrgs': {'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 = monotonic()
         job.worker_pid = 313
         job.terminate(pool, signal='TERM')
         pool.terminate_job.assert_called_with(job.worker_pid, signum)
コード例 #25
0
 def test_revoked_expires_expired(self):
     job = Request({
         'task': self.mytask.name,
         'id': uuid(),
         'args': [1],
         'kwargs': {'f': 'x'},
         'expires': datetime.utcnow() - timedelta(days=1),
     }, app=self.app)
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=True, signum=None):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(
             self.mytask.backend.get_status(job.id),
             states.REVOKED,
         )
コード例 #26
0
ファイル: test_request.py プロジェクト: rhayesbite/celery
 def test_revoked_expires_expired(self):
     job = Request(
         {
             "task": self.mytask.name,
             "id": uuid(),
             "args": [1],
             "kwargs": {"f": "x"},
             "expires": datetime.utcnow() - timedelta(days=1),
         },
         app=self.app,
     )
     with assert_signal_called(
         task_revoked, sender=job.task, request=job, terminated=False, expired=True, signum=None
     ):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(self.mytask.backend.get_status(job.id), states.REVOKED)
コード例 #27
0
 def test_revoked_expires_expired(self):
     job = Request({
         'task': self.mytask.name,
         'id': uuid(),
         'args': [1],
         'kwargs': {'f': 'x'},
         'expires': datetime.utcnow() - timedelta(days=1),
     }, app=self.app)
     with assert_signal_called(
             task_revoked, sender=job.task, request=job,
             terminated=False, expired=True, signum=None):
         job.revoked()
         self.assertIn(job.id, revoked)
         self.assertEqual(
             self.mytask.backend.get_status(job.id),
             states.REVOKED,
         )
コード例 #28
0
    def test_terminate__pool_ref(self):
        pool = Mock()
        signum = signal.SIGTERM
        job = self.get_request(self.mytask.s(1, f='x'))
        job._apply_result = Mock(name='_apply_result')
        with assert_signal_called(task_revoked,
                                  sender=job.task,
                                  request=job,
                                  terminated=True,
                                  expired=False,
                                  signum=signum):
            job.time_start = monotonic()
            job.worker_pid = 314
            job.terminate(pool, signal='TERM')
            job._apply_result().terminate.assert_called_with(signum)

            job._apply_result = Mock(name='_apply_result2')
            job._apply_result.return_value = None
            job.terminate(pool, signal='TERM')