diff options
-rw-r--r-- | mainApp.py | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -28,6 +28,8 @@ from container import Container from Graphics import Graphics import pickle import threading +import os +import ctypes ui,_ = loadUiType('main.ui') @@ -164,7 +166,20 @@ class MainApp(QMainWindow,ui): self.res.show() def terminate(self): - print('----------------------------terminate called-----------------------------') + os.chdir(self.Container.flowsheet.root_dir) + if self.thrd: + thread_id = self.thrd.ident + print('____________________Going to terminate simulation thread with Thread ID:',thread_id,'____________________') + # print('____________________Going to terminate the new process created for omc____________________') + # self.Container.flowsheet.process.terminate() + # print('____________________New process created for omc is terminated.____________________') + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, ctypes.py_object(SystemExit)) + self.textBrowser.append("<span style=\"color:red\">["+str(self.currentTime())+"]<b> Terminating the simulation </b></span>") + print('____________________Simulation thread terminated____________________') + if res > 1: + ctypes.pythonapi.PyThreadState_SetAsyncExc(thread_id, 0) + print('Exception raise (Thread termination) failure') + ''' Resets the zoom level to default scaling |