CTRL-C style interrupt of IronPython scripts in the Workbench Mechanical scripting interface?
I run scripts in the Mechanical GUI.
Sometimes, it would be convenient to interrupt a script.
However, the scripting interface in Mechanical does not respond to CTRL-C input, which would interrupt my script if I ran it in an ironpython console window.
My question: Is there any way to interrupt a running script using a) keyboard inputs or b) another method?
Thank you!
Best Answer
-
I don’t think this is possible. You can code checks to see if a file exists and then externally create that file when you want code to exit. That is the best I have been able to come up with. Mechanical is locked up while code is executing and does not support multi threaded code.
0
Answers
-
Ok, then I will use a file existence check. Thank you!
0 -
Minimal implementation for future me and others interested:
import os def abort_requester_check(abort_file): if os.path.isfile(abort_file): raise IOError("Aborting due to existence of abort file " + abort_file) counter = 0 while True: counter += 1 abort_requester_check(abort_file)
0