FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-39511: PyThreadState_Clear() calls on_delete by vstinner · Pull Request #18296 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .rst  (2) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions Doc/c-api/init.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,10 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
Reset all information in a thread state object. The global interpreter lock
must be held.

.. versionchanged:: 3.9
This function now calls the :c:member:`PyThreadState.on_delete` callback.
Previously, that happened in :c:func:`PyThreadState_Delete`.


.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The :c:func:`PyThreadState_Clear` function now calls the
:c:member:`PyThreadState.on_delete` callback. Previously, that happened in
:c:func:`PyThreadState_Delete`.
8 changes: 5 additions & 3 deletions Python/pystate.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,10 @@ PyThreadState_Clear(PyThreadState *tstate)
Py_CLEAR(tstate->async_gen_finalizer);

Py_CLEAR(tstate->context);

if (tstate->on_delete != NULL) {
tstate->on_delete(tstate->on_delete_data);
}
}


Expand All @@ -830,9 +834,7 @@ tstate_delete_common(PyThreadState *tstate,
if (tstate->next)
tstate->next->prev = tstate->prev;
HEAD_UNLOCK(runtime);
if (tstate->on_delete != NULL) {
tstate->on_delete(tstate->on_delete_data);
}

PyMem_RawFree(tstate);

if (gilstate->autoInterpreterState &&
Expand Down

Back | FazBrowse Home | New Git URL