On Tue, Mar 18, 2008 at 9:16 PM, Itamar Shtull-Trauring <<a href="mailto:itamar@itamarst.org">itamar@itamarst.org</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">
On Tue, 2008-03-18 at 20:04 +0800, Brian Baquiran wrote:<br>
> Could the part of pyactivemq (or ActiveMQ-CPP) that handles asynchronous<br>
> consumption of messages be interfering somehow with Twisted's event loop<br>
> and causing this problem?<br>
<br>
</div>Quite possibly; if the API you're calling is blocking then Twisted's<br>
event loop won't be able to run. If that is the case, either figure out<br>
if you can integrate the library with Twisted's event loop, or use<br>
twisted.internet.threads.deferToThread or something similar to call the<br>
blocking API.<br>
</blockquote></div><br>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:<br>
<a href="http://pyactivemq.googlecode.com/svn/trunk/src/examples/asynclistener.py">http://pyactivemq.googlecode.com/svn/trunk/src/examples/asynclistener.py</a><br>
<br>
In my code, I'm calling the protocol's transport.write(data) from within the onMessage() callback.<br>
<br>
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().<br>
<br>
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?<br><br>Thanks,<br>Brian<br>