From b5beae6dd067d51a606ad9a90a02496c5ba235b4 Mon Sep 17 00:00:00 2001
From: Nick Draper <nick.draper@stfc.ac.uk>
Date: Wed, 25 Mar 2020 11:51:17 +0000
Subject: [PATCH] Checkpointing -does not work yet

---
 qt/python/mantidqt/utils/asynchronous.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qt/python/mantidqt/utils/asynchronous.py b/qt/python/mantidqt/utils/asynchronous.py
index de0c478de3d..6c8838f3668 100644
--- a/qt/python/mantidqt/utils/asynchronous.py
+++ b/qt/python/mantidqt/utils/asynchronous.py
@@ -147,6 +147,11 @@ class BlockingAsyncTaskWithCallback(AsyncTask):
         """Cancel an asynchronous execution"""
         # Implementation is based on
         # https://stackoverflow.com/questions/5019436/python-how-to-terminate-a-blocking-thread
+        from mantid.api import IAlgorithm
+        alg = IAlgorithm._algorithmInThread(ctypes.c_long(self.task.ident))
+        if alg is not None:
+            alg.cancel()
+
         ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(self.task.ident),
                                                    ctypes.py_object(KeyboardInterrupt))
         time.sleep(0.1)
-- 
GitLab