➜

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.

作者 aeros
收信人 aeros, eric.snow, ncoghlan, pitrou, tomMoral, vstinner
日期 2020-02-29.02:02:43
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1582941763.47.0.513169881402.issue37266@roundup.psfhosted.org>
In-reply-to
内容
> The daemon thread itself is not problematic, because ProcessPoolExecutor uses an atexit hook to shutdown itself and therefore join the management thread.

ThreadPoolExecutor also uses an atexit hook for its shutdown process. Also, it sets each worker thread to a daemon. So we'd definitely have to address as well that prior to killing off daemon threads.

> Perhaps the solution would be to have an additional kind of atexit hooks, which get executed before threads are joined.

Hmm, a potential way to do this might be adding a form of "atexit hook" support that's specific to threads. Each registered function would get called in the internal `_shutdown()` [1] function in the threading module, just before all of the non-daemon threads are joined. To me, this seems best implemented as a new public function for the threading module, perhaps something like `threading.register_atexit()`. Would this be reasonable?

---

[1] - IIUC, `threading._shutdown()` is called in pylifecycle.c, in `wait_for_thread_shutdown()`, which is the way that non-daemon threads are joined when the interpreter shuts down in `Py_EndInterpreter()` or is finalized in `Py_FinalizeEx()`.
历史
日期 用户 动作 参数
2020-02-29 02:02:43aeros修改recipients: + aeros, ncoghlan, pitrou, vstinner, eric.snow, tomMoral
2020-02-29 02:02:43aeros修改messageid: <1582941763.47.0.513169881402.issue37266@roundup.psfhosted.org>
2020-02-29 02:02:43aeros链接issue37266 messages
2020-02-29 02:02:43aeros创建