force exit to Home screen
I'm looking for some method to force exit pythonista App and return to Home screen.
It seems that there's no such method existed?
yesterday I found that sometimes the App crashed and it suddenly exited and retuned to Home screen.
since this crash always works as expected, maybe this's the method I'm looking for?
but I wonder if this'd do any harm to my iPhone if I intentionally execute such code to force crash.?
If you really want to, you can use
os.abort()to crash the app on purpose. Be aware that this is still a crash and not a clean exit, so some things might not be saved, for example modified files in the editor, or files
opened in Python.
I'm not entirely sure if
os.abortwill generate a crash report that might get sent to Apple.
os._exit(0)might be a slightly cleaner alternative, though the same caveats about files possibly not being saved etc. apply (usually not that big of a deal because the editor automatically saves before running any script).
Just curious, why do you want to do this?
thank you all
@zrzka I'm thinking of adding script to 3D touch shortcut to quickly execute some task without remaining in the code App after task done.
when I'm a code developer, I may want to execute a script and then go to code editor to check error or add features.
after code is done, I just want to execute it and then leave, do not need to enter code editor again.
Does the script produces any output? IOW what it does? I'm asking because it's not a good practice on iOS to kill apps in anyway. And maybe you can end up somewhere else by opening URL (some other app URL scheme, ...), ...?
@shtek I use the Launcher app, as widget, to launch my scripts and at the end of my scripts, I use
which displays the home screen
@zrzka I want to exit after it produce any output, and exit on demand. I know it's not the usual ios way, but why not, if I can? I'm sure I'm not the only one who wants to do so. search this forum and I found there're some posts talking about this.
@cvp are you serious? nothing happened after that url opened. you have an App named 'crash'?
oh I see, I don't have a launch App :(
you see, there's a URL for crash, because someone needs it. I think that's os._exit also? I'm not going anywhere but my Home screen......