aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHakan Ardo <hakan@debian.org>2010-11-17 19:41:25 +0000
committerHakan Ardo <hakan@debian.org>2010-11-17 19:41:25 +0000
commitbaf678c574081d15f0e409eb8d004c76e87b95c2 (patch)
tree1b7f8e03b86f24a6c8a44ece82fcdb6e5602fce4 /pypy/module/signal/interp_signal.py
parentBetter name (diff)
downloadpypy-baf678c574081d15f0e409eb8d004c76e87b95c2.tar.gz
pypy-baf678c574081d15f0e409eb8d004c76e87b95c2.tar.bz2
pypy-baf678c574081d15f0e409eb8d004c76e87b95c2.zip
svn merge -r78744:HEAD svn+ssh://hakanardo@codespeak.net/svn/pypy/trunk
Diffstat (limited to 'pypy/module/signal/interp_signal.py')
-rw-r--r--pypy/module/signal/interp_signal.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/pypy/module/signal/interp_signal.py b/pypy/module/signal/interp_signal.py
index 26efaecfb2..73b1904075 100644
--- a/pypy/module/signal/interp_signal.py
+++ b/pypy/module/signal/interp_signal.py
@@ -1,6 +1,7 @@
from pypy.interpreter.error import OperationError
from pypy.interpreter.baseobjspace import W_Root, ObjSpace
from pypy.interpreter.executioncontext import AsyncAction, AbstractActionFlag
+from pypy.interpreter.executioncontext import PeriodicAsyncAction
import signal as cpy_signal
from pypy.rpython.lltypesystem import lltype, rffi
from pypy.translator.tool.cbuild import ExternalCompilationInfo
@@ -52,19 +53,29 @@ c_pause = external('pause', [], rffi.INT)
class SignalActionFlag(AbstractActionFlag):
- def get(self):
+ # This class uses the C-level pypysig_counter variable as the tick
+ # counter. The C-level signal handler will reset it to -1 whenever
+ # a signal is received.
+
+ def get_ticker(self):
p = pypysig_getaddr_occurred()
return p.c_value
- def set(self, value):
+
+ def reset_ticker(self, value):
p = pypysig_getaddr_occurred()
p.c_value = value
+ def decrement_ticker(self, by):
+ p = pypysig_getaddr_occurred()
+ value = p.c_value
+ if self.has_bytecode_counter: # this 'if' is constant-folded
+ value -= by
+ p.c_value = value
+ return value
-class CheckSignalAction(AsyncAction):
- """An action that is automatically invoked when a signal is received."""
- # The C-level signal handler sets the bit 30 of pypysig_occurred:
- bitmask = 1 << 30
+class CheckSignalAction(PeriodicAsyncAction):
+ """An action that is automatically invoked when a signal is received."""
def __init__(self, space):
AsyncAction.__init__(self, space)
@@ -73,7 +84,6 @@ class CheckSignalAction(AsyncAction):
# need a helper action in case signals arrive in a non-main thread
self.pending_signals = {}
self.reissue_signal_action = ReissueSignalAction(space)
- space.actionflag.register_action(self.reissue_signal_action)
else:
self.reissue_signal_action = None