diff options
-rw-r--r-- | pypy/interpreter/miscutils.py | 5 | ||||
-rw-r--r-- | pypy/module/signal/interp_signal.py | 20 | ||||
-rw-r--r-- | pypy/module/thread/threadlocals.py | 4 |
3 files changed, 9 insertions, 20 deletions
diff --git a/pypy/interpreter/miscutils.py b/pypy/interpreter/miscutils.py index 40a9531072..a6499fc7fe 100644 --- a/pypy/interpreter/miscutils.py +++ b/pypy/interpreter/miscutils.py @@ -17,9 +17,8 @@ class ThreadLocals: 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 index b8417a4db8..45df01bd92 100644 --- a/pypy/module/signal/interp_signal.py +++ b/pypy/module/signal/interp_signal.py @@ -198,15 +198,12 @@ def signal(space, signum, w_handler): 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 @@ def set_wakeup_fd(space, fd): 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 index 4bb12c13b2..7c559751e4 100644 --- a/pypy/module/thread/threadlocals.py +++ b/pypy/module/thread/threadlocals.py @@ -44,10 +44,6 @@ class OSThreadLocals: 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 |