Python Forum

Full Version: multiprocessing: when does fork really happen?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i am using the multiprocessing module on a Unix-like platform to run a bunch of worker processes. i am using a system level pipe (os.pipe() is called) to capture stdout output from each child (is there a better way?). with the multiprocessing module, a call to Process is followed by a call to process object start() method. the parent needs to os.close() its copy of the write end of the system level pipe while the child needs to close its copy of the read end. the closes need to happen only after the fork() system call is done. the documentation does not indicate when this actually happens. there is a possibility of the fork() syscall happening after the start() method is called. the calls to os.close() absolutely must not be done before fork() is called.