[Twisted-Python] pyactivemq interfering with Twisted?

Brian Baquiran brianbaquiran at gmail.com
Tue Mar 18 21:49:17 EDT 2008

On Tue, Mar 18, 2008 at 9:16 PM, Itamar Shtull-Trauring <itamar at itamarst.org>

> On Tue, 2008-03-18 at 20:04 +0800, Brian Baquiran wrote:
> > Could the part of pyactivemq (or ActiveMQ-CPP) that handles asynchronous
> > consumption of messages be interfering somehow with Twisted's event loop
> > and causing this problem?
> Quite possibly; if the API you're calling is blocking then Twisted's
> event loop won't be able to run. If that is the case, either figure out
> if you can integrate the library with Twisted's event loop, or use
> twisted.internet.threads.deferToThread or something similar to call the
> blocking API.

The API does not block when using an async message listener as I'm doing.
Here's some example pyactivemq code that shows how an asynchronous message
listener is registered:

In my code, I'm calling the protocol's transport.write(data) from within the
onMessage() callback.

In my testing, I've also seen cases wherein I consume a whole lot of
messages from ActiveMQ and call transport.write() for each of them but
nothing appears on the server (both client and server twisted apps are on
the same machine) I wait a while -- couple of seconds to a minute -- then
suddenly the data arrives on the server in a single dataReceived().

Would it work if I didn't call transport.write() from within the onMessage()
callback? Perhaps having some intermediate buffer to avoid having twisted
methods called from inside the message listener?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20080319/a16f34a6/attachment.htm 

More information about the Twisted-Python mailing list