FFI.compile is not thread safe with tmpdir
The short of it is that FFI.compile
is basically implemented as:
cwd = os.getcwd()
os.chdir(tmpdir)
ffiplatform.compile('.', ...)
os.chdir(cwd)
Because os.chdir
is a process-wide operation, if two calls to FFI.compile
use different values for tmpdir
, then one chdir
clobbers the other. Ideally, ffiplatform.compile
could be told to operate on tmpdir
in a non-racy way, but I don't know if distutils is itself thread safe. Locking this operation would be an alternative solution.