Skip to content

Commit 9c35027

Browse files
committed
PythonInterpreter: can now kill terminal (but still have crash on exit)
1 parent c1e01a3 commit 9c35027

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

PythonInterpreter/python/interp.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def main_loop(self):
160160
while self._running: #runs the eval_str queued by the server, then waits for the next eval_str. the loop ends when the server requests exit
161161
try:
162162
if self.eval_str!='':
163-
logmsg('running code '+self.eval_str)
163+
logmsg('running code ',self.eval_str)
164164
try:
165165
self.runsource(self.eval_str+'\n')
166166
logmsg('ran code')
@@ -213,7 +213,7 @@ def end(self):
213213
self._quit=True
214214
self.lock.notify()
215215
self.lock.release()
216-
return "Session Terminated"
216+
return self.cont(None)
217217
def run_code(self,eval_str,stdin):
218218
logmsg("compiling code")
219219
try:
@@ -224,14 +224,15 @@ def run_code(self,eval_str,stdin):
224224
if cobj==None:
225225
logmsg("statement incomplete")
226226
return -2,'','',False
227-
logmsg("running code "+eval_str)
227+
logmsg("running code ",eval_str)
228228
if self.interp.queue_code(eval_str):
229229
return self.cont(stdin)
230230
else:
231231
return -3,self.interp._stdout.read(),self.interp._stderr.read(),self.interp._stdin.HasInputRequest()
232232
def cont(self,stdin):
233-
logmsg('continuing with stdin: '+stdin)
234-
self.interp._stdin.write(stdin)
233+
logmsg('continuing with stdin: ',stdin)
234+
if stdin is not None:
235+
self.interp._stdin.write(stdin)
235236
if self.interp._stdin.HasInputRequest():
236237
self.interp._stdin.InputRequestNotify()
237238
self.lock.acquire()
@@ -245,6 +246,7 @@ def cont(self,stdin):
245246
def break_code(self):
246247
if self.interp._runningeval:
247248
raise KeyboardInterrupt
249+
return self.cont(None)
248250

249251
def cmd_err():
250252
print 'Correct usage: pyinterp.py <port>'

0 commit comments

Comments
 (0)