6

Is any callback function exists in python 3 to receive data from child processes without listening to them through Process.recv() or any other block-function?

I need that because I have many child processes which can send data to parent process and I don't know how to listen all child processes in same time; and I guess callback function is better instead of infinite loops like

while True:
    if self.child_pipe.poll(None):
David
  • 15,894
  • 22
  • 55
  • 66
VP.
  • 15,509
  • 17
  • 91
  • 161
  • 1
    Maybe you want to do this: http://stackoverflow.com/questions/1123855/select-on-multiple-python-multiprocessing-queues – User Nov 02 '13 at 18:22
  • 1
    You mean I should use queues for that instead of pipes? – VP. Nov 02 '13 at 20:09
  • Yes. Queues will communicate via the pipes. You can the select the pipes and get new elements out of the Queues. – User Nov 02 '13 at 21:06
  • One more question then - I have a processes which is not just parallel workers - it is different child processes that can do different actions on the same data that they may receive from pipe/queue, but if I adapt my code to queues then child processes must use task_queue.get() to get data from parent process, but if one of many child processes will get any task from task_queue - others will not receive that data and will not perform action. I need to pass each task from task_queue to all child processes and listen answer from them. How can I do that? – VP. Nov 02 '13 at 22:44
  • Open an new Question so that other people have a look at it. – User Nov 03 '13 at 13:26

0 Answers0