Need long running backend for ui-frontends
#1
Hello,

I am working on a random trailers addon which can be invoked as either a screensaver or script. I seeking some suggestions for how to overcome several issues:
  •    Each time the addon is launched, a new instance is created. I would much rather reuse an existing instance. As a minimum, the back-end needs to be reused since it is expensive to start.
  •  Should the addon be split into multiple addons: script, screensaver and backend?
Right now, there is only one addon that is exposed as a script and screensaver. This works, except I noticed that every time the script is launched that a new instance of it is created. I thought that as long as I didn't exit the previous instance that it would reuse it, but apparently I am wrong.

There is a lot of backend overhead discovering all of the trailers for movies in the library + TMDB + iTunes, as well running ffmpeg on trailers to normalize their volumes. I certainly don't want to restart this every time the script exits and I also want to share this with the screensaver. I have recently added caches that will speed things up quite a bit, but I still want to avoid all of the initial discovery, especially when the caches are cleared.

The backend, once invoked, runs until Kodi exits. The interface between front-end and back-end is basically: getNextMovieInfoToPlay.

The only difference between the script and screensaver is that they differ in a tiny bit of startup code. The docs seem to encourage shipping as separate addons. I can see where this makes it more clear to the end-user what they have enabled. It also provides the option to have separate settings (currently they are shared). I assume that if they are separate addons that the screensaver will import the script addon which will contain all of the UI and do the real work.

There is quite a bit of code in both the backend and frontend, with the back-end the largest.

Any guidance is most welcome.

Frank
Reply
#2
to prevent multiple instances of the script, you could implement some logic like this:
python:

if xbmcgui.Window(10000).getProperty('myaddon.running') == 'true':
    self.exit()
xbmcgui.Window(10000).setProperty('myaddon.running', 'true')
...
<rest of your code>
...
xbmcgui.Window(10000).clearProperty('myaddon.running')
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
Great idea.
Reply

Logout Mark Read Team Forum Stats Members Help
Need long running backend for ui-frontends0