def test_execute_using_pool_does_not_execute_revoked(self): job = TaskRequest( self.mytask.name, uuid(), [1], {'f': 'x'}, app=self.app, ) revoked.add(job.id) with self.assertRaises(TaskRevokedError): job.execute_using_pool(None)
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)
def test_revoked(self): job = self.xRequest() with self.assert_signal_called( task_revoked, sender=job.task, request=job, terminated=False, expired=False, signum=None): revoked.add(job.id) assert job.revoked() assert job._already_revoked assert job.acknowledged
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)
def test_revoke(self): ready_queue = FastQueue() l = MyKombuConsumer(ready_queue, self.eta_schedule, self.logger, send_events=False) backend = Mock() id = gen_unique_id() t = create_message(backend, task=foo_task.name, args=[2, 4, 8], kwargs={}, id=id) from celery.worker.state import revoked revoked.add(id) l.receive_message(t.decode(), t) self.assertTrue(ready_queue.empty())
def revoke(panel, task_id, task_name=None, **kwargs): """Revoke task by task id.""" revoked.add(task_id) backend = default_backend if task_name: # use custom task backend (if any) try: backend = tasks[task_name].backend except KeyError: pass backend.mark_as_revoked(task_id) panel.logger.warn("Task %s revoked" % (task_id, )) return {"ok": "task %s revoked" % (task_id, )}
def test_revoke(self): ready_queue = FastQueue() l = MyKombuConsumer(ready_queue, timer=self.timer) backend = Mock() id = uuid() t = create_message(backend, task=foo_task.name, args=[2, 4, 8], kwargs={}, id=id) from celery.worker.state import revoked revoked.add(id) l.receive_message(t.decode(), t) self.assertTrue(ready_queue.empty())
def test_revoke(self): l = _MyKombuConsumer(self.buffer.put, timer=self.timer, app=self.app) l.steps.pop() backend = Mock() id = uuid() t = create_message(backend, task=self.foo_task.name, args=[2, 4, 8], kwargs={}, id=id) from celery.worker.state import revoked revoked.add(id) callback = self._get_on_message(l) callback(t.decode(), t) self.assertTrue(self.buffer.empty())
def revoke(panel, task_id, terminate=False, signal=None, **kwargs): """Revoke task by task id.""" revoked.add(task_id) action = "revoked" if terminate: signum = get_signal(signal) for request in state.active_requests: if request.task_id == task_id: action = "terminated (%s)" % (signum, ) request.terminate(panel.consumer.pool, signal=signum) break panel.logger.warn("Task %s %s." % (task_id, action)) return {"ok": "task %s %s" % (task_id, action)}
def test_revoke(self): l = _MyKombuConsumer(self.buffer.put, timer=self.timer, app=self.app) l.blueprint.state = RUN l.steps.pop() channel = Mock() id = uuid() t = create_task_message(channel, self.foo_task.name, args=[2, 4, 8], kwargs={}, id=id) from celery.worker.state import revoked revoked.add(id) callback = self._get_on_message(l) callback(t) self.assertTrue(self.buffer.empty())
def test_mediator_move_revoked(self): ready_queue = Queue() got = {} def mycallback(value): got["value"] = value.value m = Mediator(ready_queue, mycallback) t = MockTask("Jerry Seinfeld") t.task_id = gen_unique_id() revoked_tasks.add(t.task_id) ready_queue.put(t) m.move() self.assertNotIn("value", got) self.assertTrue(t.acked)
def test_mediator_body_revoked(self): ready_queue = Queue() got = {} def mycallback(value): got["value"] = value.value m = Mediator(ready_queue, mycallback) t = MockTask("Jerry Seinfeld") t.task_id = uuid() revoked_tasks.add(t.task_id) ready_queue.put(t) m.body() self.assertNotIn("value", got) self.assertTrue(t.on_ack.call_count)
def test_execute_using_pool_does_not_execute_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}) revoked.add(tw.id) with self.assertRaises(TaskRevokedError): tw.execute_using_pool(None)
def test_revoked(self): tw = TaskRequest(mytask.name, gen_unique_id(), [1], {"f": "x"}) revoked.add(tw.task_id) self.assertTrue(tw.revoked()) self.assertTrue(tw._already_revoked) self.assertTrue(tw.acknowledged)
def test_execute_does_not_execute_revoked(self): job = self.xRequest() revoked.add(job.id) job.execute()
def test_execute_using_pool_does_not_execute_revoked(self): job = self.xRequest() revoked.add(job.id) with pytest.raises(TaskRevokedError): job.execute_using_pool(None)
def test_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}) revoked.add(tw.id) self.assertTrue(tw.revoked()) self.assertTrue(tw._already_revoked) self.assertTrue(tw.acknowledged)
def test_execute_using_pool_does_not_execute_revoked(self): tw = TaskRequest(mytask.name, gen_unique_id(), [1], {"f": "x"}) revoked.add(tw.task_id) tw.execute_using_pool(None)
def test_execute_does_not_execute_revoked(self): job = TaskRequest( self.mytask.name, uuid(), [1], {'f': 'x'}, app=self.app, ) revoked.add(job.id) job.execute()
def revoke(panel, task_id, **kwargs): """Revoke task by task id.""" revoked.add(task_id) panel.logger.warn("Task %s revoked" % (task_id, )) return {"ok": "task %s revoked" % (task_id, )}
def test_execute_using_pool_does_not_execute_revoked(self): job = self.xRequest() revoked.add(job.id) with self.assertRaises(TaskRevokedError): job.execute_using_pool(None)
def test_execute_does_not_execute_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"}) revoked.add(tw.task_id) tw.execute()
def test_execute_does_not_execute_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {'f': 'x'}) revoked.add(tw.id) tw.execute()
def test_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"}) revoked.add(tw.id) self.assertTrue(tw.revoked()) self.assertTrue(tw._already_revoked) self.assertTrue(tw.acknowledged)
def test_execute_using_pool_does_not_execute_revoked(self): tw = TaskRequest(mytask.name, uuid(), [1], {"f": "x"}) revoked.add(tw.id) tw.execute_using_pool(None)