Newbie question: how do I properly end a script?
#15
jmarshall Wrote:What does running the same thing in python do for instance?
Without the XBMC stuff? I'll try during the weekend and get back to you. I'm not sure if aborting the script in Python (CTRL-C I suppose) triggers the same events as ending it in XBMC does. Will find out. Thanks for the suggestion!

blittan Wrote:try and do a .pid file for your script once it starts, then in every loop of the script check to see if that file exists, if it is removed, then quit the script.

I will give it a try. It feels like a workaround, not solving the cause of the problem - but if it works then I'm a happy man.

blittan Wrote:User wants to stop script, launch script again. if myscript.pid exists -> remove it (will cause the running script to exit)

So that's what happens? If the user selects the script for the second time, XBMC tries to launch it a second time - not abort it? But I see no sign of that in the logfiles. I print some info when the script is launched, but it is not printed a second time when I stop it. So why would testing for the .pid file work, while printing to the logfile is not reached at the second launch?

Anyway, will give it a shot and let you know.

ppic Wrote:that the better way to do, but the file will stay if script fails.

If the script fails, I should get an exception within my script and respond to it by deleting the file - right?

LtChambers Wrote:If you have proper exception handling, you should always be able to clean up when your script raises an exception.


Sure, but I think the exception is not raised within my script. In any case I can't catch it even if I surround the entire script with a try .. except block.

LtChambers Wrote:Unless you crash python and/or XBMC, something which I've found is not hard to do, especially where threads are involved.

I ran into that yesterday when I tried to solve things with threads Laugh

Thank you all for being supportive!
Reply


Messages In This Thread
[No subject] - by VictorV - 2010-01-05, 13:04
[No subject] - by brulsmurf - 2010-01-05, 13:35
Maybe not so easy then? - by brulsmurf - 2010-01-06, 21:20
[No subject] - by blittan - 2010-01-06, 21:32
[No subject] - by brulsmurf - 2010-01-07, 11:01
[No subject] - by rwparris2 - 2010-01-07, 13:42
[No subject] - by brulsmurf - 2010-01-07, 14:19
[No subject] - by brulsmurf - 2010-01-07, 22:10
[No subject] - by jmarshall - 2010-01-08, 00:06
[No subject] - by blittan - 2010-01-08, 02:36
[No subject] - by ppic - 2010-01-08, 02:41
[No subject] - by blittan - 2010-01-08, 03:19
[No subject] - by LtChambers - 2010-01-08, 03:58
[No subject] - by brulsmurf - 2010-01-08, 09:07
[No subject] - by blittan - 2010-01-08, 09:56
[No subject] - by brulsmurf - 2010-01-08, 21:13
[No subject] - by blittan - 2010-01-08, 23:56
[No subject] - by ppic - 2010-01-09, 22:20
[No subject] - by brulsmurf - 2010-01-09, 22:26
[No subject] - by ppic - 2010-01-11, 01:31
[No subject] - by brulsmurf - 2010-01-25, 11:03
[No subject] - by matthuisman - 2010-01-26, 01:28
[No subject] - by matthuisman - 2010-01-26, 01:30
[No subject] - by brulsmurf - 2010-01-26, 09:17
[No subject] - by matthuisman - 2010-01-26, 23:28
[No subject] - by brulsmurf - 2010-01-27, 21:32
Logout Mark Read Team Forum Stats Members Help
Newbie question: how do I properly end a script?0