[Twisted-Python] Connecting to multiple servers

Antonio Beamud Montero antonio.beamud at gmail.com
Wed Jul 8 02:41:45 MDT 2009


Gerrat Rickert escribió:
> ...you could try this (slightly modified from your example):
>
> from twisted.internet import reactor, defer
> from twisted.web.client import getPage
>
> def gotPageCallback(page):
>      print "got a page!"
>
> dlist = [getPage('http://www.google.com').addCallback(gotPageCallback)]
> dlist.append(getPage('http://www.yahoo.com').addCallback(gotPageCallback
> ))
>
> defer.DeferredList(dlist).addCallback(lambda _: reactor.stop())
>
> reactor.run()
>   
Ok, but when I use reactor.connectTCP no deferred is returned.. How I 
can stop the reactor when all connections has finished?

Thanks.





More information about the Twisted-Python mailing list