[issue41962] Make threading._register_atexit public?

Ben Darnell report at bugs.python.org
Sun Jan 24 22:09:07 EST 2021


Ben Darnell <ben.darnell at gmail.com> added the comment:

> 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.

Agreed, but the problem is that I'm in a library (so I don't control the main module), and the library's interface does not mandate any sort of explicit shutdown method. There is a shutdown method, but almost no one calls it, and it's never caused a problem until Python 3.9 changed things so it deadlocks. 

> 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. 

Yes, and that is exactly the problem. concurrent.futures submits an atexit hook whose behavior depends on application code, and through that I have inadvertently caused a deadlock.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41962>
_______________________________________


More information about the Python-bugs-list mailing list