STINNER Victor <vstin...@redhat.com> added the comment:
I looked at _Py_atomic_address to avoid atomic "serialno++", but we don't have atomic_fetch_add(). We could implement it using a loop and atomic_compare_exchange_strong()... but we don't have atomic_compare_exchange_strong() neither. I tried to add a mutex, but there are some pratical issues: * bpo-35388: question about calling Py_Initialize() / Py_Finalize() multiple times * I modified _PyRuntimeState_Init() to initialize the lock. _PyRuntimeState_Init() calls PyThread_acquire_lock() which calls PyMem_RawMalloc(). Problem: PyMem_RawMalloc() requires the lock. I worked around the isuse using "if (_PyRuntime.mem.mutex != NULL) {". ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31473> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com