10000 gh-104690 Disallow thread creation and fork at interpreter finalization by chgnrdv · Pull Request #104826 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104690 Disallow thread creation and fork at interpreter finalization #104826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jun 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mentioned new behaviour and added warning about old one in atexit docs
  • Loading branch information
chgnrdv committed May 26, 2023
commit 9d0a750b4df25deb1ebb7ac0f115ecc7db81c1d1
11 changes: 11 additions & 0 deletions Doc/library/atexit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ a cleanup function is undefined.
This function returns *func*, which makes it possible to use it as a
decorator.

.. warning::
Starting new threads and process creation through :func:`os.fork`
in registered function can lead to race condition between the main
Python runtime thread freeing thread states while internal
:mod:`threading` routines are trying to allocate and use the state
of just created threads or forked children trying to use the mid-shutdown
runtime and thread state in the child process.

.. versionchanged:: 3.12
Attempt to start a new thread or create a new process through :func:`os.fork`
in registered function now leads to :exc:`RuntimeError`.

.. function:: unregister(func)

Expand Down
0