[Python-Dev] Another threading idea
Guido van Rossum
guido at python.org
Wed Mar 15 00:09:46 CET 2006
I think I was thinking of the following: create a semaphore set to
zero; the main thread does N acquire operations; each of N workers
releases it once after it's done. When the main thread proceeds it
knows all workers are done. Doesn't that work? Also, I believe Tim
once implemented a barrier lock but I can't find it right now.
--Guido
On 3/14/06, Raymond Hettinger <raymond.hettinger at verizon.net> wrote:
> > Isn't this a job for threading.BoundedSpemaphore()?
>
> I don't see how that would work. ISTM that we need an inverse of a
> BoundedSemaphore. If it understand it correctly, a BS blocks after some pre-set
> maximum number of acquires and is used for resources with limited capacity (i.e.
> a number of connections that can be served). With the TaskQueue, there is no
> pre-set number, the queue can grow to any size, and the join() method will block
> until the counter falls back to zero. IOW, a BS is about potentially blocking
> new requests and a TaskQueue is about blocking other work until outstanding
> requests are complete.
>
>
> Raymond
>
>
>
>
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list