Re: [Python-Dev] Another threading idea

2006-03-15 Thread Dave Brueck
Raymond Hettinger wrote: > FWIW, I've been working on a way to simplify the use of queues with daemon > consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task to > enter a > queue and then work on the task. A recurring problem is that I sometimes need > to

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Tim Peters
[Raymond Hettinger] > FWIW, I've been working on a way to simplify the use of queues with > daemon consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task > to enter a queue and then work on the task. A recurring problem is that > I sometimes need to know if all o

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Guido van Rossum
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

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Raymond Hettinger
> 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

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Paul Moore
On 3/14/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > Isn't this a job for threading.BoundedSpemaphore()? Not sure I see how. What I think Raymond's after (and certainly what I want) is to queue N tasks, set a counter to N, then wait until the counter goes to zero. I suppose counter = Se

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Paul Moore
On 3/14/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > FWIW, I've been working on a way to simplify the use of queues with daemon > consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task to > enter a > queue and then work on the task. A recurring problem is

Re: [Python-Dev] Another threading idea

2006-03-14 Thread Guido van Rossum
Isn't this a job for threading.BoundedSpemaphore()? On 3/14/06, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > FWIW, I've been working on a way to simplify the use of queues with daemon > consumer threads > > Sometimes, I launch one or more consumer threads that wait for a task to > enter a > que

[Python-Dev] Another threading idea

2006-03-14 Thread Raymond Hettinger
FWIW, I've been working on a way to simplify the use of queues with daemon consumer threads Sometimes, I launch one or more consumer threads that wait for a task to enter a queue and then work on the task. A recurring problem is that I sometimes need to know if all of the tasks have been comp