Skip to content

Commit 588255e

Browse files
committed
Remove module dict swapping
1 parent c6216ab commit 588255e

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

Lib/concurrent/futures/process.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ def __init__(self, executor):
296296
# if there is no pending work item.
297297
def weakref_cb(_,
298298
thread_wakeup=self.thread_wakeup,
299-
shutdown_lock=self.shutdown_lock):
300-
mp.util.debug('Executor collected: triggering callback for'
299+
shutdown_lock=self.shutdown_lock,
300+
mp_util_debug=mp.util.debug):
301+
mp_util_debug('Executor collected: triggering callback for'
301302
' QueueManager wakeup')
302303
with shutdown_lock:
303304
thread_wakeup.wakeup()

Python/pylifecycle.c

-18
Original file line numberDiff line numberDiff line change
@@ -1491,23 +1491,6 @@ finalize_modules_delete_special(PyThreadState *tstate, int verbose)
14911491
}
14921492
}
14931493

1494-
static void
1495-
swap_module_dict(PyModuleObject *mod)
1496-
{
1497-
if (_Py_IsImmortal(mod->md_dict)) {
1498-
// gh-117783: Immortalizing module dicts can cause some finalizers to
1499-
// run much later than typical leading to attribute errors due to
1500-
// partially cleared modules. To avoid this, we copy the module dict
1501-
// if it was immortalized.
1502-
PyObject *copy = PyDict_Copy(mod->md_dict);
1503-
if (copy == NULL) {
1504-
PyErr_FormatUnraisable("Exception ignored on removing modules");
1505-
return;
1506-
}
1507-
Py_SETREF(mod->md_dict, copy);
1508-
}
1509-
}
1510-
15111494
static PyObject*
15121495
finalize_remove_modules(PyObject *modules, int verbose)
15131496
{
@@ -1537,7 +1520,6 @@ finalize_remove_modules(PyObject *modules, int verbose)
15371520
if (verbose && PyUnicode_Check(name)) { \
15381521
PySys_FormatStderr("# cleanup[2] removing %U\n", name); \
15391522
} \
1540-
swap_module_dict((PyModuleObject *)mod); \
15411523
STORE_MODULE_WEAKREF(name, mod); \
15421524
if (PyObject_SetItem(modules, name, Py_None) < 0) { \
15431525
PyErr_FormatUnraisable("Exception ignored on removing modules"); \

0 commit comments

Comments
 (0)