[Twisted-Python] Multiple clients
Jason J. W. Williams
jasonjwwilliams at gmail.com
Fri Jun 18 16:58:22 EDT 2010
If you're not using twistd to launch your app you'll have to run
reactor.run(). Otherwise, the eventloop won't ever start.
In terms of exposing something like get_messages()...couldn't that
issue the callLater with a very tiny value? Or issue the first
connectTCP, which the others chained via addCallback?
On Fri, Jun 18, 2010 at 11:55 AM, Szabolcs Balogh <bszabolcs at gmail.com> wrote:
> On Friday 18 June 2010 20:25:50 Itamar Turner-Trauring wrote:
>> > It sounds good, but if I don't call reactor.run() after connectSSL
>> > doesn't happens anything... If I call reactor.run() after connectSSL, it
>> > works properly...
>> There are two types of client connections:
>> 1. Connections you open when you first run the program. Call these before
>> reactor.run() is called.
>> 2. Connections that happen as result of events. Events are all dispatched
>> by the reactor, so e.g. gui click or data received over network connection
>> will result in functions being called by the reactor. These functions can
>> also open new connections.
>> The key here is to distinguish between the order of the code in the text
>> file, and the order the code runs in. In the following example, the
>> connectTCP will happen *after* reactor.run():
>> # this will get called 10 seconds after reactor.run():
>> def happensLater():
>> reactor.callLater(10, happensLater)
>> Twisted-Python mailing list
>> Twisted-Python at twistedmatrix.com
> It is possible to:
> - start the reactor when I initialize my program (eg. in main)
> - call connectTCP or connectSSL when I want and every time I want?
> Something like this:
> def check_messages(account):
> # connect to imap server and check for new mailboxes/messages
> if __name__ == "__main__":
> do something else
> Because I can't implement this :}
> I have started the implementation based on "Twisted Network Programming
> Essential", but this book doesn't treat multiple connections...
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python