[rabbitmq-discuss] Pika disconnects
Marek Majkowski
majek04 at gmail.com
Mon Oct 10 15:38:30 BST 2011
On Mon, Oct 10, 2011 at 14:42, John Reuning <john at ibiblio.org> wrote:
> On Sat, Oct 8, 2011 at 8:50 AM, Marek Majkowski <majek04 at gmail.com> wrote:
>>
>> If you want to publish, you need to stop event loop,
>> publish, and restart event loop. It doesn't matter
>> which thread does what, but it matters that only
>> one thread accesses pika stuff at a time.
>
> I'm really only concerned with publishing. Consuming happens using
> another rabbitmq connection. When you say stop the event loop, do you
> mean the poll loop in IOLoop? The reason I implemented multiple
> threads for publishing was that the ioloop start() call doesn't
> return. Calling ioloop.start() seemed to be the only way to initiate
> a rabbitmq connection for publishing. Is there a non-blocking way to
> establish a connection? Should I call ioloop.start(), wait for the
> channel/exchange/queue callbacks to occur, then call ioloop.stop()? I
> tried this, but the stop() call hangs.
Understood. But I don't know how to do it in Pika. You may try using
blocking connection, but I don't know what actually basic_publish
does, if it blocks and for how long. See:
https://github.com/pika/pika/blob/master/examples/blocking/demo_send.py#L46
It may be possible to do some kind of synchronization trick
that could break event loop in other thread, but I don't know how.
Gavin CC'ed.
Cheers,
Marek
More information about the rabbitmq-discuss
mailing list