[pypy-svn] r77959 - pypy/branch/fast-forward/pypy/module/imp

afa at codespeak.net afa at codespeak.net
Thu Oct 14 21:58:36 CEST 2010


Author: afa
Date: Thu Oct 14 21:58:34 2010
New Revision: 77959

Modified:
   pypy/branch/fast-forward/pypy/module/imp/__init__.py
   pypy/branch/fast-forward/pypy/module/imp/importing.py
   pypy/branch/fast-forward/pypy/module/imp/interp_imp.py
Log:
Add disabled code that *could* help with the import lock
being held while another thread forks the interpreter.

Let's see if a failing test in cpython tests suite needs it.


Modified: pypy/branch/fast-forward/pypy/module/imp/__init__.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/imp/__init__.py	(original)
+++ pypy/branch/fast-forward/pypy/module/imp/__init__.py	Thu Oct 14 21:58:34 2010
@@ -34,3 +34,13 @@
 
     appleveldefs = {
         }
+
+    def __init__(self, space, *args):
+        "NOT_RPYTHON"
+        MixedModule.__init__(self, space, *args)
+        # from pypy.module.posix.interp_posix import add_fork_hook
+        # from pypy.module.imp import interp_imp
+        # add_fork_hook('before', interp_imp.acquire_lock)
+        # add_fork_hook('parent', interp_imp.release_lock)
+        # add_fork_hook('child', interp_imp.reinit_lock)
+

Modified: pypy/branch/fast-forward/pypy/module/imp/importing.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/imp/importing.py	(original)
+++ pypy/branch/fast-forward/pypy/module/imp/importing.py	Thu Oct 14 21:58:34 2010
@@ -580,6 +580,13 @@
             self.lockowner = None
             self.lock.release()
 
+    def reinit_lock(self):
+        # Called after fork() to ensure that newly created child
+        # processes do not share locks with the parent
+        self.lock = None
+        self.lockowner = None
+        self.lockcounter = 0
+
 def getimportlock(space):
     return space.fromcache(ImportRLock)
 

Modified: pypy/branch/fast-forward/pypy/module/imp/interp_imp.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/imp/interp_imp.py	(original)
+++ pypy/branch/fast-forward/pypy/module/imp/interp_imp.py	Thu Oct 14 21:58:34 2010
@@ -152,3 +152,7 @@
 def release_lock(space):
     if space.config.objspace.usemodules.thread:
         importing.getimportlock(space).release_lock()
+
+def reinit_lock(space):
+    if space.config.objspace.usemodules.thread:
+        importing.getimportlock(space).reinit_lock()



More information about the Pypy-commit mailing list