Skip to content

Instantly share code, notes, and snippets.

@oubiwann
Created October 13, 2012 21:01
Show Gist options
  • Save oubiwann/3886139 to your computer and use it in GitHub Desktop.
Save oubiwann/3886139 to your computer and use it in GitHub Desktop.
Async Batching with Twisted: A Walkthrough
from twisted.internet import reactor
from twisted.web.client import getPage
from twisted.internet.defer import DeferredList
def listCallback(results):
print results
def finish(ign):
reactor.stop()
def test():
d1 = getPage('http://www.google.com')
d2 = getPage('http://yahoo.com')
dl = DeferredList([d1, d2])
dl.addCallback(listCallback)
dl.addCallback(finish)
test()
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment