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 jbms
Recipients gregory.p.smith, izbyshev, jbms, pitrou, vstinner
Date 2021-09-26.21:42:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632692524.73.0.135454840625.issue42969@roundup.psfhosted.org>
In-reply-to
Content
Yes, I would agree that the new APIs are a useful addition regardless of the PyThread_exit_thread change.

As far as the proposed `Py_SetThreadExitCallback` that seems like a fine thing for applications to use, as long as it doesn't impact how extensions need to be written to be safe from crashes/memory corruption.  So for example if the default is to hang, then changing it to log and then hang, or optionally log and terminate the program, would be fine, since extensions aren't affected either way.

Conversely, if one of the possible behaviors may be `_endthreadex` or `pthread_exit`, then libraries must be written to be safe under that behavior anyway, which is unfortunate.  Furthermore, say for a library that only supports POSIX, maybe it is written to be safe under `pthread_exit` because it uses destructors to do cleanup, but then it will cause deadlock if the callback chooses to hang the thread instead.  Thus, I think allowing the callback to change the behavior in a way that could impact extensions is not a great idea.

The callback also doesn't seem like a very good mechanism for an extension that is incompatible with `pthread_exit` or `_endthreadex`, such as one using pybind11, to try to mitigate that problem, since an individual library shouldn't be changing application-wide behavior unless the library is specifically being used by the application for that purpose.
History
Date User Action Args
2021-09-26 21:42:04jbmssetrecipients: + jbms, gregory.p.smith, pitrou, vstinner, izbyshev
2021-09-26 21:42:04jbmssetmessageid: <1632692524.73.0.135454840625.issue42969@roundup.psfhosted.org>
2021-09-26 21:42:04jbmslinkissue42969 messages
2021-09-26 21:42:04jbmscreate