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

SourceForge.net noreply@sourceforge.net
Thu, 08 May 2003 20:04:53 -0700


Patches item #731701, was opened at 2003-05-02 22:38
Message generated for change (Comment added) made by tim_one
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: Tim Peters (tim_one)
Date: 2003-05-08 23:04

Message:
Logged In: YES 
user_id=31435

This desperately needs a doc patch too -- it's not at all 
obvious what this code does, how to use it, or why 
someone would want to.

There's a more serious problem of a different kind:  you 
didn't write the code, and apparently lifted it off a web 
page.  There's a clear copyright notice on that page, and no 
license in sight there.  So, apologies in advance, but unless 
you have permission from Mr. Kidd to distribute his work, 
we have to delete this patch.

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

Comment By: Brett Cannon (bcannon)
Date: 2003-05-08 19: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