Python Forum
Will JoinableQueue.join() always notice the counter reaching 0?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Will JoinableQueue.join() always notice the counter reaching 0?
#1
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.
Reply
#2
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/exam...nableQueue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to avoid deprecation notice merrittr 5 1,167 Nov-27-2023, 11:12 PM
Last Post: rob101
  [notice] A new release of pip available: 22.3.1 -> 23.1.2 [notice] To update, run: C: GoldenHarvey 3 5,302 Jun-06-2023, 05:43 PM
Last Post: GoldenHarvey
  The difference between os.path.join( and os.sep.join( Pedroski55 2 9,483 Nov-17-2020, 08:38 AM
Last Post: Pedroski55
  SQL select join operation in python(Select.. join) pradeepkumarbe 1 2,250 Feb-14-2019, 08:34 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020