[pypy-commit] cffi default: Acquire the import lock explicitly around the sys.setdlopenflags()
arigo
noreply at buildbot.pypy.org
Thu Apr 30 09:38:52 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r1893:5df67a682cac
Date: 2015-04-30 09:39 +0200
http://bitbucket.org/cffi/cffi/changeset/5df67a682cac/
Log: Acquire the import lock explicitly around the sys.setdlopenflags()
diff --git a/cffi/vengine_cpy.py b/cffi/vengine_cpy.py
--- a/cffi/vengine_cpy.py
+++ b/cffi/vengine_cpy.py
@@ -141,19 +141,23 @@
def load_library(self, flags=None):
# XXX review all usages of 'self' here!
# import it as a new extension module
- if hasattr(sys, "getdlopenflags"):
- previous_flags = sys.getdlopenflags()
+ imp.acquire_lock()
try:
- if hasattr(sys, "setdlopenflags") and flags is not None:
- sys.setdlopenflags(flags)
- module = imp.load_dynamic(self.verifier.get_module_name(),
- self.verifier.modulefilename)
- except ImportError as e:
- error = "importing %r: %s" % (self.verifier.modulefilename, e)
- raise ffiplatform.VerificationError(error)
+ if hasattr(sys, "getdlopenflags"):
+ previous_flags = sys.getdlopenflags()
+ try:
+ if hasattr(sys, "setdlopenflags") and flags is not None:
+ sys.setdlopenflags(flags)
+ module = imp.load_dynamic(self.verifier.get_module_name(),
+ self.verifier.modulefilename)
+ except ImportError as e:
+ error = "importing %r: %s" % (self.verifier.modulefilename, e)
+ raise ffiplatform.VerificationError(error)
+ finally:
+ if hasattr(sys, "setdlopenflags"):
+ sys.setdlopenflags(previous_flags)
finally:
- if hasattr(sys, "setdlopenflags"):
- sys.setdlopenflags(previous_flags)
+ imp.release_lock()
#
# call loading_cpy_struct() to get the struct layout inferred by
# the C compiler
More information about the pypy-commit
mailing list