提交 22967901 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

More comments

上级 1c8a8433
...@@ -390,6 +390,9 @@ class ModuleCache(object): ...@@ -390,6 +390,9 @@ class ModuleCache(object):
rval = self.module_from_name[name] rval = self.module_from_name[name]
else: else:
# we have never seen this key before # we have never seen this key before
# Acquire lock before creating things in the compile cache,
# to avoid that other processes remove the compile dire while it
# is still empty
compilelock.get_lock() compilelock.get_lock()
location = dlimport_workdir(self.dirname) location = dlimport_workdir(self.dirname)
#debug("LOCATION*", location) #debug("LOCATION*", location)
...@@ -512,8 +515,11 @@ class ModuleCache(object): ...@@ -512,8 +515,11 @@ class ModuleCache(object):
except IOError: except IOError:
has_key = False has_key = False
if not has_key: if not has_key:
#TODO: only if older than 1 week? #TODO: Remove this, or at least wait one week
# it might still be used by another process # This cache dir is either in use by another process
# (in that case, it will be removed by the code above),
# or a remnant of a crashed process, in that case, it will
# be removed by clear_old at some point.
info("clear_unversioned removing cache dir", filename) info("clear_unversioned removing cache dir", filename)
_rmtree(os.path.join(self.dirname, filename)) _rmtree(os.path.join(self.dirname, filename))
...@@ -656,7 +662,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[] ...@@ -656,7 +662,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
standard_lib=1) standard_lib=1)
python_lib = os.path.dirname(python_lib) python_lib = os.path.dirname(python_lib)
if python_lib not in lib_dirs: if python_lib not in lib_dirs:
lib_dirs.append(python_lib) lib_dirs.append(python_lib)
workdir = location workdir = location
...@@ -698,7 +704,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[] ...@@ -698,7 +704,7 @@ def gcc_module_compile_str(module_name, src_code, location=None, include_dirs=[]
raise Exception('g++ return status', status) raise Exception('g++ return status', status)
#touch the __init__ file #touch the __init__ file
file(os.path.join(location, "__init__.py"),'w').close() file(os.path.join(location, "__init__.py"),'w').close()
return dlimport(lib_filename) return dlimport(lib_filename)
def icc_module_compile_str(*args): def icc_module_compile_str(*args):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论