示例#1
0
 def test_safe_process_task_raise_regular(self):
     worker = self.worker
     worker.pool = MockPool(raise_regular=True)
     backend = MockBackend()
     m = create_message(backend, task="c.u.foo", args=[4, 8, 10], kwargs={})
     task = TaskWrapper.from_message(m, m.decode())
     worker.safe_process_task(task)
     worker.pool.stop()
示例#2
0
 def test_safe_process_task(self):
     worker = self.worker
     worker.pool = MockPool()
     backend = MockBackend()
     m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
                        kwargs={})
     task = TaskWrapper.from_message(m, m.decode())
     worker.safe_process_task(task)
     worker.pool.stop()
示例#3
0
    def receive_message(self, message_data, message):
        """The callback called when a new message is received.

        If the message has an ``eta`` we move it to the hold queue,
        otherwise we move it the bucket queue for immediate processing.

        """
        try:
            task = TaskWrapper.from_message(message, message_data,
                                            logger=self.logger)
        except NotRegistered, exc:
            self.logger.error("Unknown task ignored: %s" % (exc))
            return
示例#4
0
 def test_from_message(self):
     body = {"task": mytask.name, "id": gen_unique_id(),
             "args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
     m = BaseMessage(body=simplejson.dumps(body), backend="foo",
                     content_type="application/json",
                     content_encoding="utf-8")
     tw = TaskWrapper.from_message(m, m.decode())
     self.assertIsInstance(tw, TaskWrapper)
     self.assertEqual(tw.task_name, body["task"])
     self.assertEqual(tw.task_id, body["id"])
     self.assertEqual(tw.args, body["args"])
     self.assertEqual(tw.kwargs.keys()[0],
                       u"æØåveéðƒeæ".encode("utf-8"))
     self.assertNotIsInstance(tw.kwargs.keys()[0], unicode)
     self.assertTrue(tw.logger)