Will "hello" always be printed?

Robin van der veer robinvdveer at gmail.com
Fri Oct 7 14:16:02 EDT 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')[/python]

process 2:

    queue.get()
    queue.task_done() #unfished tasks = 0
    queue.put(1) #unfinished tasks 1[/python]
the unfished tasks refers to what is written in the documentation (
https://docs.python.org/3/library/multiprocessing.html#multiprocessing.JoinableQueue.join
)

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.


More information about the Python-list mailing list