I'm a little bit confused about BlockingConnection
and AsyncoreConnection
. I want to send some messages to the RabbitMQ queue from a Django app. Is it ok to do that using a global BlockingConnection
object?
Thank You.
You need to have one BlockingConnection
object per thread, as stated in the pika FAQ:
Pika does not have any notion of threading in the code. If you want to use Pika with threading, make sure you have a Pika connection per thread, created in that thread. It is not safe to share one Pika connection across threads.
So, the answer depends on how you're deploying Django. If you're using Django in a multi-threaded deployment, you can't use a global BlockingConnection
; you need to create one per-thread. If you're not using multi-threading, you can use a global BlockingConnection
object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With