Can I use sys.exit() ?
#1
I'm currently writing a Python script and I tried to add some exception handling but XBMC seems to crash when I do something like this:
Code:
for tries in range(5):
  try:
    ....
  except:
    if tries==5:
      sys.exit(1)

The odd thing is that it doesn't happen when I directly call sys.exit(). I'd rather use a "goto label" to jump to the end of script but the label/goto libs don't seem to be available on XBMC. Anyway knows how to fix this?

Please note that I'm still sort of a novice concerning Python coding.
-= Team Kodi developer fueled by heavy metal =-
Reply
#2
Nah it's busted. I noticed it too, but it was too late to fix for Atlantis. Definitely needs sorting. I'll try to make some time to look at it tonight.
Reply
#3
althekiller Wrote:Nah it's busted. I noticed it too, but it was too late to fix for Atlantis. Definitely needs sorting. I'll try to make some time to look at it tonight.

Thanks! Would it also be possible to implement goto/labels in the Python framework? Or do you want me to create a trac ticket for this (and maybe for the sysexit() issue too)?
-= Team Kodi developer fueled by heavy metal =-
Reply
#4
Go ahead and make a bug report for the sys.exit() thing. You can make a feat. req. for the goto thing, but I personally have no interest in enabling a means to bad programming. The only somewhat acceptable (EXTREMELY RARE!) time to use goto, IMO, is in a complex switch statement (python doesn't even have a switch statement Wink).
Reply
#5
"goto" only in dos batch files Tongue
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#6
Of course being a programmer myself I also try to stay away from goto/labels. The last time I used it was probably in the Basic-ages. But in this case it could have been an alternative to the broken sysexit()
-= Team Kodi developer fueled by heavy metal =-
Reply
#7
My alt was a nasty tree of ifs. Make sure your tab spacing is narrow!
Reply
#8
althekiller Wrote:My alt was a nasty tree of ifs. Make sure your tab spacing is narrow!

I *always* use 2-space tabs :-D Although I'd rather use a nasty goto/label than having a nasty tree of ifs ;-)
-= Team Kodi developer fueled by heavy metal =-
Reply

Logout Mark Read Team Forum Stats Members Help
Can I use sys.exit() ?0