i read about python’s “atexit” module and tried to register my clean up function , so python would quit after running the clean up function.
(because except python and panda modules, i also use ctypes to import external DLLs, and i plan to write some functions to DLL which may require cleanup, such as memory heap)
def cleanup(): time.sleep(5.0) atexit.register(cleanup)
it works, if i run the game in interactive mode - python sleeps 5 seconds before quiting.
but if i run the game with pythonw.exe , and quit the game by pressing alt+F4, pythonw doesn’t sleep, and it’s closed immediately.
if i write a cleanup function in python and activate it by a key event, it should work.
the problem is, if the user(usually me) close the app by pressing alt+F4, any cleanup procedure is skipped.
so, is there a way to intercept the key combination(alt+F4)?
i tried the accept() function of panda. it can’t do that.
btw: if a Panda app is activated by pythonw.exe, and it is closed by alt+F4, does Panda even clean up the graphic device? or is it safe to just close it? - though, i didn’t encounter a problem even if i rerun the app for many times a day.