Skip to content

Commit 2576656

Browse files
trying to finish
1 parent 290fafa commit 2576656

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

bpython/curtsiesfrontend/coderunner.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ class CodeRunner:
5757
"""Runs user code in an interpreter.
5858
5959
Running code requests a refresh by calling
60-
request_from_main_context(force_refresh=True), which
60+
request_from_main_thread(force_refresh=True), which
6161
suspends execution of the code by blocking on a queue
6262
that the main thread was blocked on.
6363
6464
After load_code() is called with the source code to be run,
6565
the run_code() method should be called to start running the code.
6666
The running code may request screen refreshes and user input
67-
by calling request_from_main_context.
67+
by calling request_from_main_thread.
6868
When this are called, the running source code cedes
6969
control, and the current run_code() method call returns.
7070
@@ -98,7 +98,7 @@ def __init__(self, interp=None, request_refresh=lambda: None):
9898
# waiting for response from main thread
9999
self.code_is_waiting = False
100100
# sigint happened while in main thread
101-
self.sigint_happened_in_main_context = False # TODO rename context to thread
101+
self.sigint_happened_in_main_thread = False # TODO rename context to thread
102102
self.orig_sigint_handler = None
103103

104104
@property
@@ -142,8 +142,8 @@ def run_code(self, for_code=None):
142142
self.code_is_waiting = False
143143
if is_main_thread():
144144
signal.signal(signal.SIGINT, self.sigint_handler)
145-
if self.sigint_happened_in_main_context:
146-
self.sigint_happened_in_main_context = False
145+
if self.sigint_happened_in_main_thread:
146+
self.sigint_happened_in_main_thread = False
147147
self.responses_for_code_thread.put(SigintHappened)
148148
else:
149149
self.responses_for_code_thread.put(for_code)
@@ -180,7 +180,7 @@ def sigint_handler(self, *args):
180180
"sigint while fulfilling code request sigint handler "
181181
"running!"
182182
)
183-
self.sigint_happened_in_main_context = True
183+
self.sigint_happened_in_main_thread = True
184184

185185
def _blocking_run_code(self):
186186
try:
@@ -192,7 +192,7 @@ def _blocking_run_code(self):
192192
if unfinished
193193
else Done())
194194

195-
def request_from_main_context(self, force_refresh=False):
195+
def request_from_main_thread(self, force_refresh=False):
196196
"""Return the argument passed in to .run_code(for_code)
197197
198198
Nothing means calls to run_code must be... ???
@@ -223,7 +223,7 @@ def __init__(self, coderunner, on_write, real_fileobj):
223223

224224
def write(self, s, *args, **kwargs):
225225
self.on_write(s, *args, **kwargs)
226-
return self.coderunner.request_from_main_context(force_refresh=True)
226+
return self.coderunner.request_from_main_thread(force_refresh=True)
227227

228228
# Some applications which use curses require that sys.stdout
229229
# have a method called fileno. One example is pwntools. This

bpython/curtsiesfrontend/interaction.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@ def process_event(self, e):
8383
assert self.in_prompt or self.in_confirm or self.waiting_for_refresh
8484
if isinstance(e, RefreshRequestEvent):
8585
self.waiting_for_refresh = False
86-
self.request_context.switch()
86+
self.request_or_notify_queue.put(None)
87+
self.response_queue.get()
8788
elif isinstance(e, events.PasteEvent):
8889
for ee in e.events:
8990
# strip control seq
9091
self.add_normal_character(ee if len(ee) == 1 else ee[-1])
9192
elif e == "<ESC>" or isinstance(e, events.SigIntEvent):
92-
self.request_context.switch(False)
93+
self.request_queue.put(False)
9394
self.escape()
9495
elif e in edit_keys:
9596
self.cursor_offset_in_line, self._current_line = edit_keys[e](

bpython/curtsiesfrontend/repl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def process_event(self, e):
112112
self.cursor_offset, self.current_line
113113
)
114114
elif isinstance(e, events.SigIntEvent):
115-
self.coderunner.sigint_happened_in_main_context = True
115+
self.coderunner.sigint_happened_in_main_thread = True
116116
self.has_focus = False
117117
self.current_line = ""
118118
self.cursor_offset = 0
@@ -164,7 +164,7 @@ def add_input_character(self, e):
164164
def readline(self):
165165
self.has_focus = True
166166
self.repl.send_to_stdin(self.current_line)
167-
value = self.coderunner.request_from_main_context()
167+
value = self.coderunner.request_from_main_thread()
168168
self.readline_results.append(value)
169169
return value
170170

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy