Threading Pool Event()
Graeme Matthew
gsmatthew at ozemail.com.au
Fri Jul 18 17:28:08 EDT 2003
Aahz
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 ?
eg: (pseudocodish :-))
def run(self):
while 1:
self.lock.acquire()
if QueueManager.HasJob:
job = QueueManager.GetFreeJob()
__processJob(job)
self.lock.release()
def __processJob(self):
blah blah blah .....
many thanks ......
"Aahz" <aahz at pythoncraft.com> wrote in message
news:bf8ri5$cs7$1 at panix1.panix.com...
> In article <0tRRa.212$vD1.8077 at nnrp1.ozemail.com.au>,
> Graeme Matthew <gsmatthew at ozemail.com.au> wrote:
> >
> >I just cannot seem to find any documentation that shows an example of
> >using the factory method Event() in threads. I have a thread pool and
> >if there are no jobs in a Queue I want them to wait for something to
> >be inserted. When a job is inserted I want to send an Event, the first
> >thread that picks it up runs with the job the rest wait for another
> >insert Event.
>
> Given that you're already using a Queue, there is no, repeat NO, reason
> for using an Event. Just have your threads block on the Queue.
> --
> Aahz (aahz at pythoncraft.com) <*>
http://www.pythoncraft.com/
>
> A: No.
> Q: Is top-posting okay?
More information about the Python-list
mailing list