diff --git a/IPython/shellglobals.py b/IPython/shellglobals.py index 7b69bec..48994bf 100644 --- a/IPython/shellglobals.py +++ b/IPython/shellglobals.py @@ -80,3 +80,17 @@ else: Term.cout.flush() # Set global flag so that runsource can know that Ctrl-C was hit KBINT = True + +def run_in_frontend(src): + """ Check if source snippet can be run in the REPL thread, as opposed to GUI mainloop + + (to prevent unnecessary hanging of mainloop). + + """ + + if src.startswith('_ip.system(') and not '\n' in src: + return True + return False + + + diff --git a/IPython/twshell.py b/IPython/twshell.py index 1a5e444..d0c2696 100644 --- a/IPython/twshell.py +++ b/IPython/twshell.py @@ -105,7 +105,7 @@ class TwistedInteractiveShell(InteractiveShell): # in IPython construction) if (not self.reactor_started or (self.worker_ident is None and not self.first_run) - or self.worker_ident == thread.get_ident()): + or self.worker_ident == thread.get_ident() or shellglobals.run_in_frontend(source)): InteractiveShell.runcode(self,code) return