Welcome!
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
-
Even the simple examples in the Standard Library docs for the
atexit
module do not seem to work in Pythonista. -
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...
-
@omz atexit seems to work fine in Pythonista 3 -- is it true? Has this issue been solved?
-
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
-
@MTcoder Now the python interpreter runs in a separate process, that's why
-
I'm on Pythonista 3 and atexit.register on its own doesn't quite work - running
sys.exit
will call the registered atexit function but forcibly terminating the program (via the stop button) doesn't do that.Using a
try..finally
like 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.