[Twisted-Python] Getting a synchronous interface to a twisted reactor

Andrey Fedorov anfedorov at gmail.com
Wed Apr 21 22:42:12 EDT 2010

I'm trying to write a dead-simple interface for an IRC client library, like

     import simpleirc

    connection = simpleirc.Connect('irc.freenode.net', 6667)
    channel = connection.join('foo')

    find_command = re.compile(r'google ([a-z]+)').findall

    for msg in channel:
        for t in find_command(msg):
            channel.say("http://google.com/search?q=%s" % t)

Working from the example in the
I'm running into trouble with the callbacks (the code is a bit lengthy, so I
pasted it here <https://gist.github.com/e7e13f074a2691de6371>). The problem
is that the call to channel.__next__ needs to be returned when the
callback <IRCClient
instance>.privmsg is called, there doesn't seem to be a clean option of
doing that. I could try to use exceptions or threads, but that seems like
the wrong thing here, is there a simpler (blocking?) way of using a twisted
reactor that would make this possible?


On Wed, Apr 21, 2010 at 10:00 PM, César García <celord at gmail.com> wrote:

> +1 Yes, it's great!!
> 2010/4/21 Kevin Horn <kevin.horn at gmail.com>
> This blog series is also totally rock-a-licious.
>> http://krondo.com/blog/?page_id=1327
> --
> http://celord.blogspot.com/
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20100421/105889a0/attachment-0001.htm 

More information about the Twisted-Python mailing list