This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
atexit module not working
Larry_Mondello last edited by
Even the simple examples in the Standard Library docs for the
atexitmodule do not seem to work in Pythonista.
omz last edited by
It's not possible to make this work on iOS. The interpreter has to run in the same process as the app, so it never terminates...
MTcoder last edited by
@omz atexit seems to work fine in Pythonista 3 -- is it true? Has this issue been solved?
JonB last edited by
atexit was added in pythonista 2.1/3.0, although it only is called when sys.exit is called, not when pythonista closes, if memory serves
Webmaster4o last edited by
@MTcoder Now the python interpreter runs in a separate process, that's why
towerofnix last edited by towerofnix
I'm on Pythonista 3 and atexit.register on its own doesn't quite work - running
sys.exitwill call the registered atexit function but forcibly terminating the program (via the stop button) doesn't do that.
try..finallylike this, worked, though:
@atexit.register def _exitcb(): print('Exit') try: # Do stuff finally: exit()
I'm not sure if that's how it would normally work on a computer running Python but that's just a tiny tidbit of hopefully helpful information for anyone coming across this issue.