Ejemplo n.º 1
0
    def get_worker(self):
        def echo(worker, body):
            if "error_occurred" in body:
                raise Exception("Error occurred")
            return body

        return Worker(
            handlers={"echo": echo},
            queue=Manager(),
        )
Ejemplo n.º 2
0
    def test_basis(self):
        queue = Manager()
        self.addCleanup(queue.close_connection)
        queue.connect()

        counter = {"n": 0}
        def on_message(body):
            self.assertEqual(body, {"message": "Hello, world!"})
            counter["n"] += 1

        queue.start_consuming(
            on_message,
        )

        queue.publish({"message": "Hello, world!"}, routing_key=queue.name)

        IOLoop.instance().add_timeout(time() + 0.2, self.stop)
        self.wait()

        self.assertEqual(counter["n"], 1)
Ejemplo n.º 3
0
 def get_publisher(self):
     return Manager()
Ejemplo n.º 4
0
    def test_handling_static_queue_name(self):
        queue = Manager(queue="dummy")
        self.addCleanup(queue.close_connection)
        queue.connect()

        self.assertEqual(queue.name, "dummy")