Kodi Community Forum

Full Version: addon startup time tradeoffs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi. I'm interested in having Remote Keys trapped and sent to a Python script, to take action such as changing the input on the AVR, or sending a Pause command to the currently active input, be it the Kodi/pi, Tivo, Blueray, FireTV. All this from the Tivo Remote.

I have some of this working now with an AddonScript, triggered from keymap.xml. Working pretty well in fact.

The response time is ok but kind of sluggish, and I want to optimize it. I also want to expand the code, and that will just add more time to the Script Execution time.

I see the following choices:

1- reduce the keymap action to the smallest tightest command, like this:
<pause>System.Exec(/storage/.kodi/myfiles/mybutton.py Pause)</pause>
This would be a 5 line script that sends a message to a second script set up as a Service, listening on a tcp port. The Kodi Keymap action only has to fork and parse the 5 lines of python code (or perl or shell).

2- run the script as a Service, in a busy wait loop, looking at a Window Property to see what to do. Then have keymap action set that window property when the key is received.

Keymap.xml has this:
<pause>SetProperty(my_button, Pause, 10000)<pause>

the script is in a loop doing this:
Code:
xbmcgui.window( 10000 ).setProperty("my_button", "nothing")
    
     while true:

         new_button = xbmcgui.window( 10000 ).getProperty("my_button")
         if new_button == "nothing"
            sleep 250ms
            continue
         xbmcgui.window( 10000 ).setProperty("my_button",  "nothing")
         act_on_the_button

Does the xmbcgui.getProperty call have a lot of overhead, and will calling it 4x per second impact other KODI actions like playing a movie?

3. Discover some other XMBC method to send a message from keymap.xml to another process, without requiring a Fork. Kind of like "Lirc.Send", but more general purpose. Then the script is not spinning 4x per second.

4. Resurrect the Persistent Addon that has now gone dormant

Any recommendations on these?
How does the xbmcgui library objects communicate between processes? Setting a Window Property in the Main Kodi process and reading that property in a child process means either shared memory or some other method of communication. Wondering what it is. That could impact the response time on this.