提交 d8cc1bae authored 作者: Frederic's avatar Frederic

Handle race condition for directory creation.

上级 02ccf5bd
import errno
import os
import sys
......@@ -248,7 +249,11 @@ fail:
loc = os.path.join(config.compiledir, 'cutils_ext')
if not os.path.exists(loc):
os.mkdir(loc)
try:
os.mkdir(loc)
except OSError, e:
assert e.errno == errno.EEXIST
assert os.path.exists(loc), loc
args = cmodule.GCC_compiler.compile_args()
cmodule.GCC_compiler.compile_str('cutils_ext', code, location=loc,
......@@ -264,7 +269,11 @@ try:
sys.path.insert(0, config.compiledir)
location = os.path.join(config.compiledir, 'cutils_ext')
if not os.path.exists(location):
os.mkdir(location)
try:
os.mkdir(location)
except OSError, e:
assert e.errno == errno.EEXIST
assert os.path.exists(location), location
if not os.path.exists(os.path.join(location, '__init__.py')):
open(os.path.join(location, '__init__.py'), 'w').close()
......
......@@ -80,7 +80,12 @@ except ImportError:
code = open(cfile).read()
loc = os.path.join(config.compiledir, dirname)
if not os.path.exists(loc):
os.mkdir(loc)
try:
os.mkdir(loc)
except OSError, e:
assert e.errno == errno.EEXIST
assert os.path.exists(loc)
args = cmodule.GCC_compiler.compile_args()
cmodule.GCC_compiler.compile_str(dirname, code, location=loc,
preargs=args)
......
import errno
import logging
import os
import sys
......@@ -61,7 +62,12 @@ except ImportError:
code = open(cfile).read()
loc = os.path.join(config.compiledir, dirname)
if not os.path.exists(loc):
os.mkdir(loc)
try:
os.mkdir(loc)
except OSError, e:
assert e.errno == errno.EEXIST
assert os.path.exists(loc)
preargs = ['-fwrapv', '-O2', '-fno-strict-aliasing']
preargs += cmodule.GCC_compiler.compile_args()
# Cython 19.1 always use the old NumPy interface. So we
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论