Pythonista hung- can't stop program. Stop (X) button was disabled
After stopping execution of the script (below) while it was running, the stop(X) button was permanently disabled, and the Start (Right Arrow) button was not visible.
Attached are Dropbox links for the script and a screenshot, showing the state of the Stop button.
Please let me know if these links do not work (IS THERE A WAY TO ATTACH FILES IN THIS FORUM?????)
This script does nothing useful, it was just a simple example to type in to give Pythonista a test.
Normally, I would have added a Ctrl-C exception handler to exit gracefully by manually stopping the thread. Since there is no Ctrl key on an iPad I can't implement Ctrl-C.
Exiting Pythonista did not help. I had to reboot the iPad.
@cappy If you don't swipe to remove an app, the app remains running in the background for a short time.Swiping to remove an app won't completely stop background processes, but will stop the main app.
Cases in which it won't stop include, for example, your mail client that listening for new emails in the background.
Not swiping away an app also does not guarantee that it will keep running. When iOS needs RAM, it quits background apps that you haven't used recently. The only way to keep an app permanently open is by making it play "music" or use the microphone or something.
@Webmaster4o I may be wrong, but when you swipe away an app I think you'll only receive push notifications, which are handled by a standard system service, and not by an app-specific background process. The built-in Mail app has the ability to check for mail every x minutes even when the main app isn't running in the background, but I think that's something only Apple can do.
@dgelessus No, I see it in other apps. I can quit the app, but still receive notifications. The following come to mind as apps I've used over the years with the ability to check for updates in the background when quit:
- Inbox by Gmail (my email client)
- Trivia Crack
- Clash of Clans
- YouTube (It can send notifications when subscribed accounts publish videos)
These all send notifications which are obviously not pre-scheduled because they rely on external events as triggers for these notifications.
@Webmaster4o Those apps don't have to be running for you to get notifications. The notifications are sent by some server (e.g. Twitter) to an Apple server, and that Apple server delivers all notifications to your device. A system service is listening for notifications, regardless of which apps are running.
@omz Wasn't aware of that. I thought they all implemented their own background processes. That's pretty neat.
From my experience if the stop button in the console doesn't seem to work (seems to be an intermittent bug), swiping back to the script page and hitting the stop button there usually works.
swiping back to the script page and hitting the stop button there
What do you mean? The script page was visible, no swiping was needed.
@cappy Oh. apologies. I figured you were on the console since it automatically slides out when a script is run as opposed to the actual editable script "code" page. Sometimes the x button on the console page (which presumably is supposed to mirror the button on the code page) doesn't do so.
I think calling exit() in the thread isn't a good idea. Better to let main exit under controlled conditions in case some cleanup is needed.
I ended up adding a KeyboardInterrupt handler in the thread AND in main().
You don't know where the execution will be when Ctrl-C is sent. I wanted both bases covered.
The Ctrl-C handler in the thread simply prints a message (so I know which handler caught the Ctrl-C), then calls self.stop(). The thread just exits gracefully.
In main, the Ctrl-C handler checks if the thread is running, if it is, self.stop() is called, a message is printed, the loop broken out of.
Sorry I didn't paste my code, I had to fix a broken drawer last night. It took longer than expected (but my head was thinking about this thread hang issue) ;-)
I didn't see the original hang problem, but when I run my solution, 1 out of 6 times I do see an exception related to the thread switching.
I hope to paste that code tonight.
I need to run at least 20+ times to make sure the hang doesn't occur again.
Here is a link to my current code, with the Ctrl-C handlers added.
I haven't been able to duplicate the unresponsive X button with this code as of yet,
but I do see an occasional exception.
Dang- I forgot about this dorky forum software- not taking attachments. Can we get some decent forum software going here so we can post attachments directly??
This is really annoying.
Here's the exception screenshot
Here's the current code