mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-10 20:00:27 +00:00
remove locking context managers
This commit is contained in:
parent
d5543c8f78
commit
e043046e43
2 changed files with 29 additions and 34 deletions
|
@ -531,7 +531,6 @@ def _module_repr_from_spec(spec):
|
||||||
def _exec(spec, module):
|
def _exec(spec, module):
|
||||||
"""Execute the spec's specified module in an existing module's namespace."""
|
"""Execute the spec's specified module in an existing module's namespace."""
|
||||||
name = spec.name
|
name = spec.name
|
||||||
with _ModuleLockManager(name):
|
|
||||||
if sys.modules.get(name) is not module:
|
if sys.modules.get(name) is not module:
|
||||||
msg = 'module {!r} not in sys.modules'.format(name)
|
msg = 'module {!r} not in sys.modules'.format(name)
|
||||||
raise ImportError(msg, name=name)
|
raise ImportError(msg, name=name)
|
||||||
|
@ -613,7 +612,6 @@ def _load(spec):
|
||||||
clobbered.
|
clobbered.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
with _ModuleLockManager(spec.name):
|
|
||||||
return _load_unlocked(spec)
|
return _load_unlocked(spec)
|
||||||
|
|
||||||
|
|
||||||
|
@ -816,7 +814,6 @@ def _find_spec(name, path, target=None):
|
||||||
# sys.modules provides one.
|
# sys.modules provides one.
|
||||||
is_reload = name in sys.modules
|
is_reload = name in sys.modules
|
||||||
for finder in meta_path:
|
for finder in meta_path:
|
||||||
with _ImportLockContext():
|
|
||||||
try:
|
try:
|
||||||
find_spec = finder.find_spec
|
find_spec = finder.find_spec
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@ -911,7 +908,6 @@ _NEEDS_LOADING = object()
|
||||||
|
|
||||||
def _find_and_load(name, import_):
|
def _find_and_load(name, import_):
|
||||||
"""Find and load the module."""
|
"""Find and load the module."""
|
||||||
with _ModuleLockManager(name):
|
|
||||||
module = sys.modules.get(name, _NEEDS_LOADING)
|
module = sys.modules.get(name, _NEEDS_LOADING)
|
||||||
if module is _NEEDS_LOADING:
|
if module is _NEEDS_LOADING:
|
||||||
return _find_and_load_unlocked(name, import_)
|
return _find_and_load_unlocked(name, import_)
|
||||||
|
@ -921,7 +917,6 @@ def _find_and_load(name, import_):
|
||||||
'None in sys.modules'.format(name))
|
'None in sys.modules'.format(name))
|
||||||
raise ModuleNotFoundError(message, name=name)
|
raise ModuleNotFoundError(message, name=name)
|
||||||
|
|
||||||
_lock_unlock_module(name)
|
|
||||||
return module
|
return module
|
||||||
|
|
||||||
|
|
||||||
|
|
2
third_party/python/Python/import.c
vendored
2
third_party/python/Python/import.c
vendored
|
@ -1613,7 +1613,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
||||||
Py_DECREF(value);
|
Py_DECREF(value);
|
||||||
if (initializing == -1)
|
if (initializing == -1)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (initializing > 0) {
|
if (0 && initializing > 0) {
|
||||||
value = _PyObject_CallMethodIdObjArgs(interp->importlib,
|
value = _PyObject_CallMethodIdObjArgs(interp->importlib,
|
||||||
&PyId__lock_unlock_module, abs_name,
|
&PyId__lock_unlock_module, abs_name,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue