This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author janfrederik.konopka
Recipients aeros, janfrederik.konopka, pitrou, tomMoral, vstinner
Date 2021-04-26.23:08:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1619478533.94.0.0540746427519.issue39812@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2021-04-26 23:08:54janfrederik.konopkasetrecipients: + janfrederik.konopka, pitrou, vstinner, tomMoral, aeros
2021-04-26 23:08:53janfrederik.konopkasetmessageid: <1619478533.94.0.0540746427519.issue39812@roundup.psfhosted.org>
2021-04-26 23:08:53janfrederik.konopkalinkissue39812 messages
2021-04-26 23:08:53janfrederik.konopkacreate