Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r59152:85d8aae437d8
Date: 2012-11-30 08:59 -0800
http://bitbucket.org/pypy/pypy/changeset/85d8aae437d8/

Log:    Baaaah. After a fork(), we change gil_ready to False and then back
        to True, which has the effect of throwing away all JIT assembler.
        :-( Fixed.

diff --git a/pypy/module/thread/gil.py b/pypy/module/thread/gil.py
--- a/pypy/module/thread/gil.py
+++ b/pypy/module/thread/gil.py
@@ -24,11 +24,14 @@
         space.actionflag.register_periodic_action(GILReleaseAction(space),
                                                   use_bytecode_counter=True)
 
+    def _initialize_gil(self, space):
+        if not thread.gil_allocate():
+            raise wrap_thread_error(space, "can't allocate GIL")
+
     def setup_threads(self, space):
         """Enable threads in the object space, if they haven't already been."""
         if not self.gil_ready:
-            if not thread.gil_allocate():
-                raise wrap_thread_error(space, "can't allocate GIL")
+            self._initialize_gil(space)
             self.gil_ready = True
             result = True
         else:
@@ -46,9 +49,8 @@
         return result
 
     def reinit_threads(self, space):
-        if self.gil_ready:
-            self.gil_ready = False
-            self.setup_threads(space)
+        if self.gil_ready:     # re-initialize the gil if needed
+            self._initialize_gil(space)
 
 
 class GILReleaseAction(PeriodicAsyncAction):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to