Visitar URL original
gh-104341: Clean Up threading Module by ericsnowcurrently · Pull Request #104552 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
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
Call on_delete() in remove_module_thread().
  • Loading branch information
ericsnowcurrently committed May 15, 2023
commit 05aa205de5d944edfee1116bb8b7a6447c19a73b
7 changes: 7 additions & 0 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ module_thread_finished(struct module_thread *mt)
static void
remove_module_thread(struct module_threads *threads, struct module_thread *mt)
{
// Notify other threads that this one is done.
// XXX This should happen in module_thread_finished().
// XXX These fields could be removed from PyThreadState.
if (mt->tstate->on_delete != NULL) {
mt->tstate->on_delete(mt->tstate->on_delete_data);
}

// Remove it from the list.
module_threads_remove(threads, mt);

Expand Down
4 changes: 0 additions & 4 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,10 +1490,6 @@ PyThreadState_Clear(PyThreadState *tstate)

Py_CLEAR(tstate->context);

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

tstate->_status.cleared = 1;

// XXX Call _PyThreadStateSwap(runtime, NULL) here if "current".
Expand Down