I am using @anonymous_ghoster example at How to signal slots in a GUI from a different process? to implement multiprocessing.
My code have:
class ChildProc(Process):
def __init__(self, to_emitter: Pipe, from_mother: Queue, daemon=True):
super().__init__()
self.daemon = daemon
self.to_emitter = to_emitter
self.data_from_mother = from_mother
def run(self):
while True:
text = self.data_from_mother.get()
print(text)
if(text[0] == "dostuff"):
dostuff(self.to_emitter)
if(text[0] == "dostuff" and text[1]=="stop"):
# until dostuff() is running, this will not hit.
stop_do_stuff()
def dostuff(conn):
while True:
# Somehow I want to be able to return from this function if requested by parent_process
The question I have is, how do I return from dostuff
function if the parent process send something like self.process_queue.put(["dostuff", "stop"])