[Twisted-Python] I could swear I've seen this pattern *somewhere* in Twisted...
James Y Knight
foom at fuhm.net
Mon May 9 20:47:54 MDT 2005
How about this? sem.run simplifies things a lot.
Note also consumeErrors=True to DL. You probably always want that,
as it causes the errors to not get propagated to the toplevel error
printer, but rather only reported by the DL.
def parallel( iterable, count, callable, *args, **named ):
sem = defer.DeferredSemaphore(count)
dl = [sem.run(callable, item, *args, **named) for item in iterable]
return defer.DeferredList(dl, consumeErrors=True)
James
More information about the Twisted-Python
mailing list