Shutdown Event in XBMC
#1
Hello,

I am currently in the process of developing an addon that automatically wake ups my fileserver when XBMC starts up and sends it to hibernate mode when XBMC shuts down.

Therefore I implemented a service according to the guidelines in the wiki. Currently the service is implemented like this:

Code:
wakeupServer()
while (not xbmc.abortRequested):
  x = 0
  # do anything useless
shutdownServer()

This however raises my CPU usage to 100% probably rendering XBMC unusable on single core systems (my setup consists of a dual core system so XBMC still runs smoothly). My question are:

What would be the most elegant way to wait for the XBMC to shut down? Is there a sleep command that can be configured more fine-grained than only seconds (like with time.sleep())?

Or is there even a hook that gets called whenever XBMC shuts down so that I can replace the while-loop?

Thanks in advance
lagwagon667
Reply
#2
xbmc.sleep(miliseconds)
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
In Frodo you can also sublcass an xbmc.Monitor() instance which's 'onAbortRequested()'-Method will be called from XBMC when abort is requested.

See here the documentation: http://mirrors.xbmc.org/docs/python-docs...ml#Monitor

You can also see an example implemention here: https://github.com/dersphere/script.scre...default.py
This waits for the 'onScreensaverDeactivated()'-call, but you can just replace it with 'onAbortRequested()'
My GitHub. My Add-ons:
Image
Reply
#4
Thanks for your answers. One additional question about the shutdown process:

I realized that during python scripts are being killed during the shutdown process after a certain period (that's why I don't want to wait a whole second in the loop in order to lose as few time as possible for my shutdown method). Is it possible to customize the period before python gets killed or is there some other preferred way to execute a long-running script during shutdown without running into the aforementioned timeout?

Cheers
lagwagon667
Reply

Logout Mark Read Team Forum Stats Members Help
Shutdown Event in XBMC1