Kodi Community Forum
Determine if XBMC is closing? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: Determine if XBMC is closing? (/showthread.php?tid=67487)



Determine if XBMC is closing? - ammmze - 2010-01-16

Hi there,
I am working on the callerid script which is basically a never ending loop running in the background. Because of this though, when you go close XBMC it just doesn't work. So i need a conditional in the loop to tell it to exit. Is there a way i can determine if XBMC is closing down?


- ammmze - 2010-01-21

BUMP

anybody got any suggestions on how to break the loop when xbmc is shutting down?


Possible Workaround - mr. kav - 2010-01-22

Hi,

I have a background script running while XBMC is shutting down and I managed to work around it by creating a time.sleep(5) endless loop. The short interval allows XBMC to shutdown within maximum of 5 seconds, because that's when the thread will be released. In order to support longer intervals, I have a modulo check within the loop, so for example a minute would be something like:
timeline_interval = 0
while 1:
----if (timeline_interval % 12 == 0): #one minute
--------print 'do something'

timeline_interval = timeline_interval + 1
time.sleep(5)

Not sure if that's what you're looking for, but maybe you or someone else will find it useful.

--mr. kav


- ammmze - 2010-01-22

Well after some more investigating, I found where the source of the problem actually lies. It was actually getting caught up in the socket connection, so it wasn't the loop. So I had to add a timeout to the socket, because actually what was happening was it was sitting there listening to the socket and wouldn't finish the script. so now that there is a timeout on the socket connection, it works great.

Thanks for the suggestion though. I see what you were saying.