Thanks! The main reason for the question, though, is just curiosity from playing with and learning the Twisted API, not necessarily getting the example working :)<div><br></div><div>A more direct question would have been - is there a Twisted reactor which provides a blocking call instead of a callback? Is there an accepted &quot;best&quot; way of wrapping an non-blocking async API with callbacks into a blocking synchronous one?</div>

<div><br></div><div>- Andrey<br><br><div class="gmail_quote">On Thu, Apr 22, 2010 at 12:40 AM, Alexandre Quessy <span dir="ltr">&lt;<a href="mailto:alexandre@quessy.net">alexandre@quessy.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello Andrey,<br>
May I recommend you to look at Twisted Words? There are plenty of IRC<br>
tools there.<br>
<br>
Regards,<br>
Alex<br>
<br>
<br>
2010/4/21 Andrey Fedorov &lt;<a href="mailto:anfedorov@gmail.com">anfedorov@gmail.com</a>&gt;:<br>
<div><div></div><div class="h5">&gt; I&#39;m trying to write a dead-simple interface for an IRC client library, like<br>
&gt; so:<br>
&gt;     import simpleirc<br>
&gt;     connection = simpleirc.Connect(&#39;<a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a>&#39;, 6667)<br>
&gt;     channel = connection.join(&#39;foo&#39;)<br>
&gt;     find_command = re.compile(r&#39;google ([a-z]+)&#39;).findall<br>
&gt;     for msg in channel:<br>
&gt;         for t in find_command(msg):<br>
&gt;             channel.say(&quot;<a href="http://google.com/search?q=%s" target="_blank">http://google.com/search?q=%s</a>&quot; % t)<br>
&gt; Working from the example in the docs, I&#39;m running into trouble with the<br>
&gt; callbacks (the code is a bit lengthy, so I pasted it here). The problem is<br>
&gt; that the call to channel.__next__ needs to be returned when the<br>
&gt; callback &lt;IRCClient instance&gt;.privmsg is called, there doesn&#39;t seem to be a<br>
&gt; clean option of doing that. I could try to use exceptions or threads, but<br>
&gt; that seems like the wrong thing here, is there a simpler (blocking?) way of<br>
&gt; using a twisted reactor that would make this possible?<br>
&gt; Cheers,<br>
&gt; Andrey<br>
&gt;<br>
&gt; On Wed, Apr 21, 2010 at 10:00 PM, César García &lt;<a href="mailto:celord@gmail.com">celord@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; +1 Yes, it&#39;s great!!<br>
&gt;&gt;<br>
&gt;&gt; 2010/4/21 Kevin Horn &lt;<a href="mailto:kevin.horn@gmail.com">kevin.horn@gmail.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; This blog series is also totally rock-a-licious.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; <a href="http://krondo.com/blog/?page_id=1327" target="_blank">http://krondo.com/blog/?page_id=1327</a><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; <a href="http://celord.blogspot.com/" target="_blank">http://celord.blogspot.com/</a><br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Twisted-Python mailing list<br>
&gt;&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt;&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Twisted-Python mailing list<br>
&gt; <a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
&gt; <a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Alexandre Quessy<br>
<a href="http://alexandre.quessy.net/" target="_blank">http://alexandre.quessy.net/</a><br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br></div>