Created
September 23, 2011 22:16
-
-
Save robhaswell/1238587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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