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

10 lines
335 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import random
from twisted.internet import reactor, task, defer
from twisted.python.util import println
delay = lambda: 1e-4*random.random()
d = defer.DeferredList([task.deferLater(reactor, delay(), println, line)
for line in 'Enjoy Rosetta Code'.split()])
d.addBoth(lambda _: reactor.stop())
reactor.run()