On Tue, Mar 18, 2008 at 9:16 PM, Itamar Shtull-Trauring &lt;<a href="mailto:itamar@itamarst.org">itamar@itamarst.org</a>&gt; 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>
&gt; Could the part of pyactivemq (or ActiveMQ-CPP) that handles asynchronous<br>
&gt; consumption of messages be interfering somehow with Twisted&#39;s event loop<br>
&gt; and causing this problem?<br>
<br>
</div>Quite possibly; if the API you&#39;re calling is blocking then Twisted&#39;s<br>
event loop won&#39;t be able to run. If that is the case, either figure out<br>
if you can integrate the library with Twisted&#39;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&#39;m doing. Here&#39;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&#39;m calling the protocol&#39;s transport.write(data) from within the onMessage() callback.<br>
<br>
In my testing, I&#39;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&#39;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>