[Twisted-Python] Connecting to multiple servers

Antonio Beamud Montero antonio.beamud at gmail.com
Tue Jul 7 11:13:33 MDT 2009


Hi all:
What's the smart way to close the reactor and exit in an app like that:

-------------------------
from twisted.internet import reactor
from twisted.web.client import getPage

def gotPageCallback(page):
     print "got a page!"

getPage('http://www.google.com').addCallback(gotPageCallback)
getPage('http://www.yahoo.com').addCallback(gotPageCallback)

reactor.run()
--------------------------

For example with a global counter and when reach to 2, then reactor.stop()?

If I use reactor.connectTCP a Connector object is returned and no
deferred to work with... How do I know when the connection has finished?

Greetings.





More information about the Twisted-Python mailing list