summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2006-03-24 13:05:53 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2006-03-24 13:05:53 (GMT)
commitc841bb6b638b34639d1371fd870839787cfd6ba1 (patch)
tree45c9ab7596e40abf9c42d3ce3172c8e89528e43e /Lib
parentcdb7948f970f389b1b3811e2491ec75adea36d97 (diff)
downloadcpython-c841bb6b638b34639d1371fd870839787cfd6ba1.zip
cpython-c841bb6b638b34639d1371fd870839787cfd6ba1.tar.gz
cpython-c841bb6b638b34639d1371fd870839787cfd6ba1.tar.bz2
run_module shouldn't hold the import lock when running a script
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/runpy.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index afb0098..496b095 100755
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -379,21 +379,17 @@ def _run_module_code(code, init_globals=None,
restore_module = mod_name in sys.modules
if restore_module:
saved_module = sys.modules[mod_name]
- imp.acquire_lock()
+ sys.argv[0] = mod_fname
+ sys.modules[mod_name] = temp_module
try:
- sys.argv[0] = mod_fname
- sys.modules[mod_name] = temp_module
- try:
- _run_code(code, mod_globals, init_globals,
- mod_name, mod_fname, mod_loader)
- finally:
- sys.argv[0] = saved_argv0
- if restore_module:
- sys.modules[mod_name] = saved_module
- else:
- del sys.modules[mod_name]
+ _run_code(code, mod_globals, init_globals,
+ mod_name, mod_fname, mod_loader)
finally:
- imp.release_lock()
+ sys.argv[0] = saved_argv0
+ if restore_module:
+ sys.modules[mod_name] = saved_module
+ else:
+ del sys.modules[mod_name]
# Copy the globals of the temporary module, as they
# may be cleared when the temporary module goes away
return mod_globals.copy()