Commits

Armin Rigo committed e2d958c

Fix and simplify set_interrupt() by reusing code from perform().

  • Participants
  • Parent commits 12c1f05

Comments (0)

Files changed (1)

pypy/module/signal/interp_signal.py

             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: