RosettaCodeData/Task/Concurrent-computing/Python/concurrent-computing-7.py

10 lines
335 B
Python
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
import random
2019-09-12 10:33:56 -07:00
from twisted.internet import reactor, task, defer
from twisted.python.util import println
2013-04-10 16:57:12 -07:00
delay = lambda: 1e-4*random.random()
2019-09-12 10:33:56 -07:00
d = defer.DeferredList([task.deferLater(reactor, delay(), println, line)
for line in 'Enjoy Rosetta Code'.split()])
d.addBoth(lambda _: reactor.stop())
reactor.run()