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

2010-04-22 Thread Andrey Fedorov
On Thu, Apr 22, 2010 at 11:00 AM, Phil Mayers wrote: > I would recommend just trying to use the API in the Twisted "way". You can > use the aforementioned @inlineCallbacks decorator & generator syntax if you > prefer writing your code that way, as opposed to traditional deferred > callback chainin

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

2010-04-22 Thread Phil Mayers
On 22/04/10 15:50, Andrey Fedorov wrote: > On Thu, Apr 22, 2010 at 3:21 AM, Phil Mayers > wrote: > > If that's the case, then the answer is "sort of" but I think you > might have misunderstood Twisted a bit. The entire point is to > have non-blocking API

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

2010-04-22 Thread Andrey Fedorov
On Thu, Apr 22, 2010 at 3:21 AM, Phil Mayers wrote: > If that's the case, then the answer is "sort of" but I think you might have > misunderstood Twisted a bit. The entire point is to have non-blocking APIs, > not to want a blocking API. > That sounds like might be the case case. Wwhat I'm lookin

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

2010-04-22 Thread Phil Mayers
On 04/22/2010 07:06 AM, Andrey Fedorov wrote: > 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 :) > > A more direct question would have been - is there a Twisted reactor > which prov

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

2010-04-21 Thread Konrads Smelkovs
You can execute blocking call at any time of your pleasing. It will predictable block all execution paths. Typical wrapper around blocking calls is thread. Something like this (from http://twistedmatrix.com/documents/current/core/howto/threading.html): d = threads.deferToThread(yourSyncCall) d.add

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

2010-04-21 Thread Andrey Fedorov
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 :) A more direct question would have been - is there a Twisted reactor which provides a blocking call instead of a callback? Is there an a

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

2010-04-21 Thread Alexandre Quessy
Hello Andrey, May I recommend you to look at Twisted Words? There are plenty of IRC tools there. Regards, Alex 2010/4/21 Andrey Fedorov : > I'm trying to write a dead-simple interface for an IRC client library, like > so: >     import simpleirc >     connection = simpleirc.Connect('irc.freenode.

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

2010-04-21 Thread Andrey Fedorov
I'm trying to write a dead-simple interface for an IRC client library, like so: 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