You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesdocsDocumentation in the Doc dirstdlibPython modules in the Lib dirtype-featureA feature request or enhancement
Ideally, we would get rid of daemon threads (as a feature) eventually. See my DPO thread. In the meantime, it makes sense (to me) to at least clarify the docs about daemon threads and steer users away from using them.
That includes the following:
clearly identify the case(s) where daemon threads might be a suitable solution
explicitly point out that daemon threads do not detach at exit, nor cause the process to move into the background at exit
a warning note indicating that daemon threads should be avoided
a brief example of using non-daemon threads to accomplish the same thing
3.12bugs and security fixes3.13bugs and security fixes3.14new features, bugs and security fixesdocsDocumentation in the Doc dirstdlibPython modules in the Lib dirtype-featureA feature request or enhancement
Feature or enhancement
Ideally, we would get rid of daemon threads (as a feature) eventually. See my DPO thread. In the meantime, it makes sense (to me) to at least clarify the docs about daemon threads and steer users away from using them.
That includes the following:
existing docs: https://docs.python.org/3/library/threading.html#thread-objects
Really the only case where daemon threads might be suitable is where:
Otherwise:
Examples
Note that many of these examples make use of
threading._register_atexit()
, which currently isn't public API, nor documented.Short-running task in a loop
The code for a function that supports timeouts is essentially the same.
Task that supports interruption or stopping
Long-running Python func from a third-party package
Long-running, uninterruptible, third-party task
About your only option is something like
signal.pthread_kill()
:The text was updated successfully, but these errors were encountered: