kushaldas/retask

Document one-to-many uses?

ralphbean opened this issue · 3 comments

I tried a setup where there was one task producer and N task consumers and ran into threading issues.

Say the consumers looked like:

while queue.length != 0:
    task = queue.dequeue()
    print task.data

On the first line, queue.length would in fact be the value 1 (one), but by the time one thread gets to line 2, another thread could already have dequeued.

Are there any 'mutex' type mechanisms in retask? If not, that's ok. Let's write one :)

In the consumers you can use

task = queue.wait()

then they will be no issues as they will get tasks as first come first serve basis.

I should update the examples showing one should check if the task dequeued is None or not.

👍 :)