Skip to content

Instantly share code, notes, and snippets.

@robhaswell
Created September 23, 2011 22:16
Show Gist options
  • Save robhaswell/1238586 to your computer and use it in GitHub Desktop.
Save robhaswell/1238586 to your computer and use it in GitHub Desktop.
while True:
# XXX need to yield to
bytes = self.message_spool_file.read(1024)
if not bytes:
for protocol in protocols:
protocol.finish()
break
def make_worker(protocol):
print "*"*30, "Made a worker for %s bytes" % (len(bytes),)
def worker(null):
print "*"*30, "Writing %s bytes" % (len(bytes),)
protocol.write(bytes)
d = defer.Deferred()
d.addCallback(worker)
return d
task = cooperate(make_worker(protocol) for protocol in protocols)
task.start()
yield task.whenDone()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment