Richard Oudkerk added the comment: On 03/06/2013 1:02am, spresse1 wrote: > Whats really bugging me is that it remains open and I can't fetch a reference. > If I could do either of these, I'd be happy. > ... > Perhaps I really want to be implementing with os.fork(). Sigh, I was trying > to > save myself some effort...
I don't see how using os.fork() would make things any easier. In either case you need to prepare a list of fds which the child process should close before it starts, or alternatively a list of fds *not* to close. The real issue is that there is no way for multiprocessing (or os.fork()) to automatically infer which fds the child process is going to use: if don't explicitly close unneeded ones then the child process will inherit all of them. It might be helpful if multiprocessing exposed a function to close all fds except those specified -- see close_all_fds_except() at http://hg.python.org/sandbox/sbt/file/5d4397a38445/Lib/multiprocessing/popen_spawn_posix.py#l81 Remembering not to close stdout (fd=1) and stderr (fd=2), you could use it like def foo(reader): close_all_fds_except([1, 2, reader.fileno()]) ... r, w = Pipe(False) p = Process(target=foo, args=(r,)) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18120> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com