@@ -43,14 +43,15 @@ class SystemExitRequest(RequestFromCodeGreenlet):
4343class CodeRunner (object ):
4444"""Runs user code in an interpreter.
4545
46- Running code requests a refresh by calling refresh_and_get_value(), which
46+ Running code requests a refresh by calling
47+ request_from_main_greenlet(force_refresh=True), which
4748 suspends execution of the code and switches back to the main greenlet
4849
4950 After load_code() is called with the source code to be run,
5051 the run_code() method should be called to start running the code.
5152 The running code may request screen refreshes and user input
52- by callingthe refresh_and_get_value and wait_and_get_value calls
53- respectively. Whenthese are called, the running source code cedes
53+ by callingrequest_from_main_greenlet.
54+ Whenthis are called, the running source code cedes
5455 control, and the current run_code() method call returns.
5556
5657 The return value of run_code() determines whether the method ought
@@ -154,19 +155,15 @@ def _blocking_run_code(self):
154155return SystemExitRequest
155156return Unfinished if unfinished else Done
156157
157- def wait_and_get_value (self ):
158+ def request_from_main_greenlet (self , force_refresh = False ):
158159"""Return the argument passed in to .run_code(for_code)
159160
160- Nothing means calls to run_code must be...
161+ Nothing means calls to run_code must be... ???
161162 """
162- value = self .main_greenlet .switch (Wait )
163- if value is SigintHappened :
164- raise KeyboardInterrupt ()
165- return value
166-
167- def refresh_and_get_value (self ):
168- """Returns the argument passed in to .run_code(for_code) """
169- value = self .main_greenlet .switch (Refresh )
163+ if force_refresh :
164+ value = self .main_greenlet .switch (Refresh )
165+ else :
166+ value = self .main_greenlet .switch (Wait )
170167if value is SigintHappened :
171168raise KeyboardInterrupt ()
172169return value
@@ -177,7 +174,7 @@ def __init__(self, coderunner, on_write):
177174self .on_write = on_write
178175def write (self ,* args ,** kwargs ):
179176self .on_write (* args ,** kwargs )
180- return self .coderunner .refresh_and_get_value ( )
177+ return self .coderunner .request_from_main_greenlet ( force_refresh = True )
181178def writelines (self ,l ):
182179for s in l :
183180self .write (s )