Eryk Sun <eryk...@gmail.com> added the comment:

multiprocessing could be redesigned to make the child process responsible for 
duplicating all handles from its logical parent (by PID passed on the command 
line -- regardless of whatever its real parent is). That avoids the problem of 
the parent mistakenly duplicating handles to a launcher child process that has 
no idea that the parent has done this and certainly doesn't have the 
architecture in place to deal with it. 

That said, inserting the launcher process as a middle man for every worker 
process is wasteful. Creating processes without fork is expensive. Also, 
relying on the "__PYVENV_LAUNCHER__" environment variable for this is 
problematic. Environment variables are inherited by default, so it leaks to a 
completely unrelated python.exe process. For example, if we run 
subprocess.call(r'C:\Program Files\Python37\python.exe') from a virtual 
environment, currently we end up with an overridden sys.executable. I would 
prefer a -X command-line option, such as "VIRTUAL_ENV". multiprocessing could 
propagate this option to worker processes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35797>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to