Feature or enhancement
The warnings implementation is split between Python (warnings.py) and C (_warnings.c). There are a few bits of code in the C module that are not thread-safe without the GIL:
The Py_SETREF calls are not thread-safe if concurrent writers try to overwrite the same field (e.g., st->once_registry). We can probably use critical sections to make it thread-safe.
get_once_registry:
|
Py_SETREF(st->once_registry, registry); |
get_default_action:
|
Py_SETREF(st->default_action, default_action); |
get_filter:
|
Py_SETREF(st->filters, warnings_filters); |
Some uses of borrowed references are likely not thread-safe
_PyDict_GetItemWithError (replace with PyDict_GetItemRef?)
Linked PRs
Feature or enhancement
The
warningsimplementation is split between Python (warnings.py) and C (_warnings.c). There are a few bits of code in the C module that are not thread-safe without the GIL:The
Py_SETREFcalls are not thread-safe if concurrent writers try to overwrite the same field (e.g.,st->once_registry). We can probably use critical sections to make it thread-safe.get_once_registry:cpython/Python/_warnings.c
Line 259 in df4784b
get_default_action:cpython/Python/_warnings.c
Line 290 in df4784b
get_filter:cpython/Python/_warnings.c
Line 315 in df4784b
Some uses of borrowed references are likely not thread-safe
_PyDict_GetItemWithError(replace withPyDict_GetItemRef?)Linked PRs