Threading Pool Event()
logiplex at qwest.net
Sat Jul 19 00:28:48 CEST 2003
On Fri, 2003-07-18 at 14:28, Graeme Matthew wrote:
> Thanks, ive actually been using your OSCON slides which have helped a lot.
> So it technically correct that all worker threads in a thread pool are
> either doing some work or polling the queue to find out if there is a job
> to process ?
They don't poll the queue, they block waiting on it until something is
> eg: (pseudocodish :-))
> def run(self):
> while 1:
> if QueueManager.HasJob:
> job = QueueManager.GetFreeJob()
> def __processJob(self):
> blah blah blah .....
job = queue.get() # this blocks until something is queue.put()
Acquiring the locks isn't necessary and ill-advised. The Queue itself
can be thought of as a type of locking mechanism, so you raise the
possibility of a deadlock condition by nesting locks (for instance if
you also put locks around the queue.put()).
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 (800) 735-0555
More information about the Python-list