-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
Description
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:
Line 259 in df4784b
| Py_SETREF(st->once_registry, registry); |
get_default_action:
Line 290 in df4784b
| Py_SETREF(st->default_action, default_action); |
get_filter:
Line 315 in df4784b
| Py_SETREF(st->filters, warnings_filters); |
Some uses of borrowed references are likely not thread-safe
_PyDict_GetItemWithError(replace withPyDict_GetItemRef?)