Author: Armin Rigo <[email protected]>
Branch:
Changeset: r55549:e2d958c646fd
Date: 2012-06-10 20:29 +0200
http://bitbucket.org/pypy/pypy/changeset/e2d958c646fd/
Log: Fix and simplify set_interrupt() by reusing code from perform().
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
@@ -148,28 +148,26 @@
n = pypysig_poll()
if n < 0:
break
- if self.reissue_signal_action is None:
- # no threads: we can report the signal immediately
+ self.perform_signal(n)
+
+ def perform_signal(self, n):
+ if self.reissue_signal_action is None:
+ # no threads: we can report the signal immediately
+ self.report_signal(n)
+ else:
+ main_ec = self.space.threadlocals.getmainthreadvalue()
+ if executioncontext is main_ec:
+ # running in the main thread: we can report the
+ # signal immediately
self.report_signal(n)
else:
- main_ec = self.space.threadlocals.getmainthreadvalue()
- if executioncontext is main_ec:
- # running in the main thread: we can report the
- # signal immediately
- self.report_signal(n)
- else:
- # running in another thread: we need to hack a bit
- self.pending_signals[n] = None
- self.reissue_signal_action.fire_after_thread_switch()
+ # running in another thread: we need to hack a bit
+ self.pending_signals[n] = None
+ self.reissue_signal_action.fire_after_thread_switch()
def set_interrupt(self):
"Simulates the effect of a SIGINT signal arriving"
- n = cpy_signal.SIGINT
- if self.reissue_signal_action is None:
- self.report_signal(n)
- else:
- self.pending_signals[n] = None
- self.reissue_signal_action.fire_after_thread_switch()
+ self.perform_signal(cpy_signal.SIGINT)
def report_signal(self, n):
try:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit