[pypy-commit] pypy default: Uh, thread+signal+fork. Tons of fun.

arigo noreply at buildbot.pypy.org
Fri Feb 15 19:41:29 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r61283:15f640136dbf
Date: 2013-02-15 19:41 +0100
http://bitbucket.org/pypy/pypy/changeset/15f640136dbf/

Log:	Uh, thread+signal+fork. Tons of fun.

diff --git a/pypy/module/thread/threadlocals.py b/pypy/module/thread/threadlocals.py
--- a/pypy/module/thread/threadlocals.py
+++ b/pypy/module/thread/threadlocals.py
@@ -77,5 +77,13 @@
 
     def reinit_threads(self, space):
         "Called in the child process after a fork()"
+        # clear the _signalsenabled dictionary for all other threads
+        # (which are now dead); and for the current thread, force an
+        # enable_signals() if necessary.  That's a hack but I cannot
+        # figure out a non-hackish way to handle thread+signal+fork :-(
+        ident = rthread.get_ident()
+        old = self._signalsenabled.get(ident, 0)
         self._signalsenabled.clear()
-        self.enable_signals()
+        if old == 0:
+            old = 1
+        self._signalsenabled[ident] = old


More information about the pypy-commit mailing list