[Twisted-Python] Multiple clients

Itamar Turner-Trauring itamar at itamarst.org
Fri Jun 18 13:25:50 EDT 2010

> 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)

More information about the Twisted-Python mailing list