I am developing a PyMAPDL script that has mistakes in it (it's a work in progress!) and when I run it, it keeps crashing out before the code can reach mapdl.exit()
. This means that my spun-up MAPDL instance remains hanging and I have to kill it manually via task manager.
I want to write a function using atexit that can exit MAPDL sensibly. However, I may not have access to the mapdl
object.
I am running the code in a script like the following:
try:
func()
except Exception as error:
print(Exception(error))
raise
In this case func()
contains the mapdl
object generated from launch_mapdl()
. Can I get it using any PyMAPDL commands and close any hanging MAPDL instances on exit?