I am trying to implement a multiprocessing queue so that I can have a shared condition that can be used from two different processes.
To understand better, I am starting two functions at the same time and I want the second one to finish after the first one notify that the condition is fulfilled.
def function_1(m_queue=multiprocessing.Queue):
time.sleep(60)
condition=m_queue.pop()
time.sleep(60)
condition.notify()
print("F1: Done")
def function_2():
condition = Condition()
multi_queue = multiprocessing.Queue()
multi_queue.put(condition)
with condition:
p1=Process(target=function_1, args=(multi_queue, ), daemon=True)
p1.start()
condition.wait()
print("Finished")
if __name__ == "__main__":
function_2()
I am getting the problem that
RuntimeError: Condition objects should only be shared between processes through inheritance
Which kind of confuses me why it happens since my expectations where that the shared space with the multiprocessing queue should have given access to both processes to the same condition.