Skip to content
Snippets Groups Projects
Unverified Commit cb8d1b8c authored by Gigg, Martyn Anthony's avatar Gigg, Martyn Anthony Committed by GitHub
Browse files

Merge pull request #28430 from mantidproject/28310_cancel_script_during_alg_in_workbench

cancel algorithm when cancelling script in workbench
parents ac112db0 6d8d7c39
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,8 @@ Improvements
- The plot selection dialog now correctly shows the full range of valid spectra to plot, not just the min to max range.
- Tile plots are now reloaded correctly by project recovery.
- When you stop a script running in workbench it will now automatically attempt to cancel the algorithm the script is running, rather than wait for the current algorthm to end.
This is similar to what Mantidplot does, and should result in the script stopping much sooner.
- Fixed an issue where some scripts were running slower if a plot was open at the same time.
......
......@@ -13,7 +13,7 @@ import sys
import threading
import time
from traceback import extract_tb
from mantid.api import IAlgorithm
from enum import Enum
......@@ -83,6 +83,10 @@ class AsyncTask(threading.Thread):
# https://stackoverflow.com/questions/5019436/python-how-to-terminate-a-blocking-thread
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.ident),
ctypes.py_object(KeyboardInterrupt))
#now try and cancel the running algorithm
alg = IAlgorithm._algorithmInThread(self.ident)
if alg is not None:
alg.cancel()
time.sleep(0.1)
......@@ -147,6 +151,10 @@ class BlockingAsyncTaskWithCallback(AsyncTask):
# https://stackoverflow.com/questions/5019436/python-how-to-terminate-a-blocking-thread
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.task.ident),
ctypes.py_object(KeyboardInterrupt))
#now try and cancel the running algorithm
alg = IAlgorithm._algorithmInThread(self.task.ident)
if alg is not None:
alg.cancel()
time.sleep(0.1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment