##// END OF EJS Templates
twshell: run _ip.system in frontend (to avoid long-term blocking of mainloop)
Ville M. Vainio -
Show More
@@ -80,3 +80,17 b' else:'
80 Term.cout.flush()
80 Term.cout.flush()
81 # Set global flag so that runsource can know that Ctrl-C was hit
81 # Set global flag so that runsource can know that Ctrl-C was hit
82 KBINT = True
82 KBINT = True
83
84 def run_in_frontend(src):
85 """ Check if source snippet can be run in the REPL thread, as opposed to GUI mainloop
86
87 (to prevent unnecessary hanging of mainloop).
88
89 """
90
91 if src.startswith('_ip.system(') and not '\n' in src:
92 return True
93 return False
94
95
96
@@ -105,7 +105,7 b' class TwistedInteractiveShell(InteractiveShell):'
105 # in IPython construction)
105 # in IPython construction)
106
106
107 if (not self.reactor_started or (self.worker_ident is None and not self.first_run)
107 if (not self.reactor_started or (self.worker_ident is None and not self.first_run)
108 or self.worker_ident == thread.get_ident()):
108 or self.worker_ident == thread.get_ident() or shellglobals.run_in_frontend(source)):
109 InteractiveShell.runcode(self,code)
109 InteractiveShell.runcode(self,code)
110 return
110 return
111
111
General Comments 0
You need to be logged in to leave comments. Login now