[rabbitmq-discuss] (pika) slow asyncore loop?

Marek Majkowski majek04 at gmail.com
Wed Jan 26 11:52:34 GMT 2011


> The thing is, callbacks apparently happen before asyncore loop can do
> another iteration.
>
> Loop:
>
> while respnum < servnum:
>        pika.asyncore_loop(count=1)
>        respnum += 1
>        print 'respnum', respnum, 'at',
> datetime.datetime.now().strftime('%H:%S')

This loop is plain wrong. During one asyncore_loop anything can happen.
You can't assume that you received a message. You could
have received a single packet, or a timeout, or yet something
else.

I'm afraid the only way to check if you really received a message
is to create some side effet in basic_consume callback.
And use this side effect as a condition for this loop.
Just like the 6th tutorial does.

> 2nd iteration of asyncore loop happened 20 seconds later than callback
> (. recvd) happened.

Sounds like some kind of timeout, isn't it?

> Is there any way to deal with it, other than rather naive solutions like
> delaying basic_publish in server?

Somehow the 6th tutorial works.

Cheers,
   Marek


More information about the rabbitmq-discuss mailing list