[Twisted-Python] I could swear I've seen this pattern *somewhere* in Twisted...

Mike C. Fletcher mcfletch at rogers.com
Mon May 9 21:02:42 EDT 2005


Itamar Shtull-Trauring wrote:

>On Mon, 2005-05-09 at 13:42 -0400, Mike C. Fletcher wrote:
>  
>
>>I have a little utility module "parallel", that dispatches a callable
>>for "count" items in parallel, collecting them as would a DeferredList
>>(attached for reference).  The idea here is that you want only count
>>items to be actively processing at any given time, and you want to be
>>notified when the entire suite of items completes processing (just like
>>a DeferredList).
>>    
>>
>
>Hm. Would t.i.defer.DeferredSemaphore do what you want? There's also
>DeferredQueue (courtesy of JP, 2.0 and later).
>  
>
DeferredSemaphore certainly makes it much simpler!  Attached so that
others can see how much it simplifies the pattern. Not quite short
enough to be "too short to bother wrapping in a function", but far less
involved all-in-all, and really too short even to bother with a class.

Thanks,
Mike

-- 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: parallel.py
Url: http://twistedmatrix.com/pipermail/twisted-python/attachments/20050509/8a75f996/attachment.txt 


More information about the Twisted-Python mailing list