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 aeros
Recipients Ben.Darnell, aeros, pitrou, vstinner
Date 2021-01-24.19:30:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1611516622.76.0.611691817616.issue41962@roundup.psfhosted.org>
In-reply-to
Content
> I'm dealing with a subtle deadlock involving concurrent.futures.ThreadPoolExecutor, and my solution that worked in Python 3.8 broke with 3.9. I'm running some long-running (possibly infinite) tasks in the thread pool, and I cancel them in an `atexit` callback so that everything can shut down cleanly (before ThreadPoolExecutor joins all worker threads in its own `atexit` hook).

IMO, a better practice would be providing those potentially infinite running tasks a direct method of escape and invoking it before calling executor.shutdown(), it would be a more reliable approach. But, perhaps there is some convenience utility in being able to provide custom atexit hooks. It also might help the user to separate the shutdown logic from the rest of the program. 

Since you worked with me in adding threading._register_atexit(), Do you have any thoughts, Antoine? I would personally not be opposed to it being made public assuming there's real utility present in doing so.

My only concern is that it might be a potential foot-gun. If the user submits an atexit hook that deadlocks, it might prevent threads from shutting down safely prior to interpreter finalization. I'm presently undecided if explicitly mentioning that it in the docs would be sufficient warning.
History
Date User Action Args
2021-01-24 19:30:22aerossetrecipients: + aeros, pitrou, vstinner, Ben.Darnell
2021-01-24 19:30:22aerossetmessageid: <1611516622.76.0.611691817616.issue41962@roundup.psfhosted.org>
2021-01-24 19:30:22aeroslinkissue41962 messages
2021-01-24 19:30:22aeroscreate