Quantcast
Channel: Kodi Community Forum - All Forums
Viewing all articles
Browse latest Browse all 84005

Python: Suspend/Resume handling for Scripts

$
0
0
Hi,

it would be nice to have a way to check if a user triggered the suspend action in Python scripts which always run in the background, to have the addon perform proper suspend actions.

I can think of something similar to xbmc.abortrequest, maybe an enhanced variant which scripts could read and do appropriate if/elif stuff. For compatibility reasons, xbmc.abortRequested should stay, of course.

Script-pseudocode of that idea:

Code:
abortrequested = False
while not abortrequested:
  # read in XBMC suspend/shutdown requests
  # returns False when nothing requested
  xbmcrequest = xbmc.getrequest()

  if xbmcrequest:
    if xbmcrequest == REQ_SUSPEND:
      self.handleSuspend()
    elif xbmcrequest == REQ_SHUTDOWN:
      abortrequested = True

  self.doAddonStuff()
  sleep(10)

self.handleShutdown()

Regards,
Daniel

Viewing all articles
Browse latest Browse all 84005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>