mirror of https://github.com/python/cpython.git
bpo-46070: Fix asyncio initialisation guard (GH-30423)
If init flag is set, exit successfully immediately. If not, only set the flag after successful initialization.
This commit is contained in:
parent
994f90c077
commit
b127e70a8a
|
@ -0,0 +1,2 @@
|
|||
Fix possible segfault when importing the :mod:`asyncio` module from
|
||||
different sub-interpreters in parallel. Patch by Erlend E. Aasland.
|
|
@ -3318,17 +3318,14 @@ static int
|
|||
module_init(void)
|
||||
{
|
||||
PyObject *module = NULL;
|
||||
if (module_initialized) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
asyncio_mod = PyImport_ImportModule("asyncio");
|
||||
if (asyncio_mod == NULL) {
|
||||
goto fail;
|
||||
}
|
||||
if (module_initialized != 0) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
module_initialized = 1;
|
||||
}
|
||||
|
||||
current_tasks = PyDict_New();
|
||||
if (current_tasks == NULL) {
|
||||
|
@ -3389,6 +3386,7 @@ module_init(void)
|
|||
goto fail;
|
||||
}
|
||||
|
||||
module_initialized = 1;
|
||||
Py_DECREF(module);
|
||||
return 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue