[pypy-commit] pypy stm-thread-2: hg merge default

arigo noreply at buildbot.pypy.org
Thu Jan 31 15:19:46 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: stm-thread-2
Changeset: r60770:393048c68eb3
Date: 2013-01-31 14:49 +0100
http://bitbucket.org/pypy/pypy/changeset/393048c68eb3/

Log:	hg merge default

diff --git a/pypy/interpreter/miscutils.py b/pypy/interpreter/miscutils.py
--- a/pypy/interpreter/miscutils.py
+++ b/pypy/interpreter/miscutils.py
@@ -17,9 +17,8 @@
     def setvalue(self, value):
         self._value = value
 
-    def getmainthreadvalue(self):
-        return self._value
+    def ismainthread(self):
+        return True
 
     def getallvalues(self):
         return {0: self._value}
-
diff --git a/pypy/module/signal/interp_signal.py b/pypy/module/signal/interp_signal.py
--- a/pypy/module/signal/interp_signal.py
+++ b/pypy/module/signal/interp_signal.py
@@ -198,15 +198,12 @@
     A signal handler function is called with two arguments:
     the first is the signal number, the second is the interrupted stack frame.
     """
-    ec = space.getexecutioncontext()
-    main_ec = space.threadlocals.getmainthreadvalue()
-
-    old_handler = getsignal(space, signum)
-
-    if ec is not main_ec:
+    if not space.threadlocals.ismainthread():
         raise OperationError(space.w_ValueError,
                              space.wrap("signal() must be called from the "
                                         "main thread"))
+    old_handler = getsignal(space, signum)
+
     action = space.check_signal_action
     if space.eq_w(w_handler, space.wrap(SIG_DFL)):
         pypysig_default(signum)
@@ -231,13 +228,10 @@
 
     The fd must be non-blocking.
     """
-    if space.config.objspace.usemodules.thread:
-        main_ec = space.threadlocals.getmainthreadvalue()
-        ec = space.getexecutioncontext()
-        if ec is not main_ec:
-            raise OperationError(
-                space.w_ValueError,
-                space.wrap("set_wakeup_fd only works in main thread"))
+    if not space.threadlocals.ismainthread():
+        raise OperationError(
+            space.w_ValueError,
+            space.wrap("set_wakeup_fd only works in main thread"))
     old_fd = pypysig_set_wakeup_fd(fd)
     return space.wrap(intmask(old_fd))
 
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
@@ -49,10 +49,6 @@
             self._mostrecentkey = ident
             self._mostrecentvalue = value
 
-    def getmainthreadvalue(self):
-        ident = self._mainthreadident
-        return self._valuedict.get(ident, None)
-
     def ismainthread(self):
         return thread.get_ident() == self._mainthreadident
 


More information about the pypy-commit mailing list