1

i've got a main thread that produces work for my worker threads.

What is the best way in python to set the worker threads to waiting till they get new work?

The thread will halt at a line like this:

new_work = self.worklist.get(block=True)

Where self.worklist is a Queue object

until the main thread delivers new work.

Or do I halt it like this:

self.wait_for_work.wait()
new_work = self.worklist.get(block=False)

where self.wait_for_work is a threading.event object and we assume the main thread already put a new work item into the fifo on the other side.

Is there something I'm missing here or will this do more or less the same?

Any clarifications?

Regards

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.