Skip to content

Commit

Permalink
Refs #11692. Add third argument to our_run_code().
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed May 5, 2015
1 parent fc452b2 commit a27e9e6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Code/Mantid/MantidPlot/ipython_widget/mantid_ipython_widget.py
Expand Up @@ -14,7 +14,7 @@
from IPython.qt.inprocess import QtInProcessKernelManager


def our_run_code(self, code_obj):
def our_run_code(self, code_obj, result=None):
""" Method with which we replace the run_code method of IPython's InteractiveShell class.
It calls the original method (renamed to ipython_run_code) on a separate thread
so that we can avoid locking up the whole of MantidPlot while a command runs.
Expand All @@ -23,12 +23,19 @@ def our_run_code(self, code_obj):
----------
code_obj : code object
A compiled code object, to be executed
result : ExecutionResult, optional
An object to store exceptions that occur during execution.
Returns
-------
False : Always, as it doesn't seem to matter.
"""
t = threading.Thread(target=self.ipython_run_code, args=[code_obj])
t = threading.Thread()
#ipython 3.0 introduces a third argument named result
try:
t = threading.Thread(target=self.ipython_run_code, args=[code_obj,result])
except TypeError:
t = threading.Thread(target=self.ipython_run_code, args=[code_obj])
t.start()
while t.is_alive():
QtGui.QApplication.processEvents()
Expand Down

0 comments on commit a27e9e6

Please sign in to comment.