pythonrabbitmqpika

Using a Pika Channel across multiple threads


Though it is clear not to use a single PIKA connection across multiple threads, can we use the channel got of the connection across multiple threads. I was getting this error doing so, and the answer seems to be no. Just posting for reference

INFO  2019-02-07 13:14:12,927 pika.connection _on_terminate  2095: Disconnected from RabbitMQ at 127.0.0.1:5672 (505): UNEXPECTED_FRAME - expected content header for class 60, got non content header frame instead

Solution

  • Though it is clear not to use a single PIKA connection across multiple threads, can we use the channel got of the connection across multiple threads.

    I am one of Pika's maintainers and no, you can't use connections or channels across threads. This is documented.