[Patches] [ python-Patches-731701 ] SpawnedGenerator class for threading module

SourceForge.net noreply@sourceforge.net
Thu, 08 May 2003 16:56:27 -0700


Patches item #731701, was opened at 2003-05-02 19:38
Message generated for change (Comment added) made by bcannon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=731701&group_id=5470

Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Mathieu Fenniak (laotzu0)
Assigned to: Nobody/Anonymous (nobody)
Summary: SpawnedGenerator class for threading module

Initial Comment:
The attached patch adds a new class, threading.SpawnedGenerator, 
written by Garth T Kidd in his weblog.  (http://
www.deadlybloodyserious.com/Python/2003/04/22.html)  The class 
wraps a given generator as a new generator that runs in a seperate 
thread by retrieving the generator values and storing them in a Queue 
object.  It's a very nice high-level threading interface.  A basic 
functionality test has also been added to test_threading.py.

----------------------------------------------------------------------

>Comment By: Brett Cannon (bcannon)
Date: 2003-05-08 16:56

Message:
Logged In: YES 
user_id=357491

First off, I think if this patch belongs anywhere it is in itertools and 
definitely not in 'threading'.  Raymond?

Second, I don't like overriding __call__ to return the generator.  It would be 
better to just put the body of __call__ into __iter__; the idiom of making 
__iter__ a generator is great by preventing someone from having to specify a 
separate 'next' method and by making __iter__ create a *new* iterator with 
fresh values without having to do some fancy class stuff.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=731701&group_id=5470