Jan Konopka <janfrederik.kono...@gmail.com> added the comment:

Hi all!

While browsing StackOverflow I came across this question: 
https://stackoverflow.com/q/67273533/2111778

The user created a ThreadPoolExecutor which started a Process using 
multiprocessing. The Process produces an exitcode of 0 in Python 3.8 but an 
exitcode of 1 in Python 3.9.

I'm really not familiar with Python internals, but through monkey-patching 
Lib/concurrent/futures/thread.py I was able to pin this regression down to the 
change of 
> atexit.register(_python_exit)
to
> threading._register_atexit(_python_exit)
which led me to this issue! (:

I know that multiprocessing in Python is a little funky, since I worked with it 
on my Master's thesis. I think the entire process gets forked (i.e. copied), so 
the child process also gets a copy of the active ThreadPoolExecutor, which I 
think causes some sort of problem there. Note that this behavior seems to 
differ based on OS. I can confirm the issue on Linux with the 'fork' method and 
disconfirm it with the 'spawn' and 'forkserver' methods.
https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods

Could someone with more insight kindly take a look at this?

Greetings Jan <3

----------
nosy: +janfrederik.konopka

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

Reply via email to