Python Forum
Will JoinableQueue.join() always notice the counter reaching 0? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Will JoinableQueue.join() always notice the counter reaching 0? (/thread-38385.html)



Will JoinableQueue.join() always notice the counter reaching 0? - RobinVeer - Oct-06-2022

If I have two processes communicating through a JoinableQueue, and I do the following:

process 1:

    queue.put(1) #unfished tasks = 1
    queue.join() #block until unfished tasks = 0
    print('hello')
process 2:

    queue.get() 
    queue.task_done() #unfished tasks = 0
    queue.put(1) #unfinished tasks 1
the unfished tasks refers to what is written in the documentation

will 'hello' always be printed? Or is there a chance that the put in process 2 executes before process 1 noticed that it should unblock?

It seems that the whole point of join() is that 'hello' should always be printed, but I just want to make sure that I understand it correctly.


RE: Will JoinableQueue.join() always notice the counter reaching 0? - Larz60+ - Oct-07-2022

I think 'hello' will be printed, but haven't used this method of multiprocessing, so suggest viewing the following webpage, where there are many examples of using join and task_done here: https://www.programcreek.com/python/example/57787/multiprocessing.JoinableQueue