GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — simple fix (ctrl-c handling probably doesn't work in all cases) · SivanSong/bpython@35beff8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • bpython/curtsiesfrontend
    • coderunner.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎bpython/curtsiesfrontend/coderunner.py‎

Copy file name to clipboardExpand all lines: bpython/curtsiesfrontend/coderunner.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"""
1414

1515
import code
16+
import threading
1617
import signal
1718
import greenlet
1819
import logging
@@ -130,16 +131,19 @@ def run_code(self, for_code=None):
130131
if source code is complete, returns "done"
131132
if source code is incomplete, returns "unfinished"
132133
"""
134+
is_main_thread = isinstance(threading.current_thread(), threading._MainThread)
133135
if self.code_context is None:
134136
assert self.source is not None
135137
self.code_context = greenlet.greenlet(self._blocking_run_code)
136-
self.orig_sigint_handler = signal.getsignal(signal.SIGINT)
137-
signal.signal(signal.SIGINT, self.sigint_handler)
138+
if is_main_thread:
139+
self.orig_sigint_handler = signal.getsignal(signal.SIGINT)
140+
signal.signal(signal.SIGINT, self.sigint_handler)
138141
request = self.code_context.switch()
139142
else:
140143
assert self.code_is_waiting
141144
self.code_is_waiting = False
142-
signal.signal(signal.SIGINT, self.sigint_handler)
145+
if is_main_thread:
146+
signal.signal(signal.SIGINT, self.sigint_handler)
143147
if self.sigint_happened_in_main_context:
144148
self.sigint_happened_in_main_context = False
145149
request = self.code_context.switch(SigintHappened)
@@ -157,7 +161,8 @@ def run_code(self, for_code=None):
157161
return False
158162
elif isinstance(request, (Done, Unfinished)):
159163
self._unload_code()
160-
signal.signal(signal.SIGINT, self.orig_sigint_handler)
164+
if is_main_thread:
165+
signal.signal(signal.SIGINT, self.orig_sigint_handler)
161166
self.orig_sigint_handler = None
162167
return request
163168
elif isinstance(request, SystemExitRequest):

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.