fixing xbmc.abortRequested
#1
So I am attempting to keep some orphaned scripts running in Kodi 19.  I tried naively just replacing some statements like
Code:
if not xbmc.abortRequested:
with
Code:
if not xbmc.Monitor().abortRequested():
and while that runs, on a couple of scripts when user initiates shutdown I get logged
Code:
trigger Monitor abort request
and
Code:
script didn't stop in 5 seconds - let's kill it

These scripts seemed to exit OK before, so I wonder what I am doing wrong?

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix
Leia see: 304472
Reply
#2
Can you point to the actual code?
Reply
#3
One thing to look for is if there are any instances of xbmc.sleep(x).  That is a blocker, and the script won't exit until the sleep timer expires.  That can be replaced with xbmc.Monitor().waitForAbort(y).  There are two big differences.  First, waitForAbort will terminate as soon as an abort is requested.  Second, the parameter for waitForAbort is SECONDS, where as xbmc.sleep is in MILLISECONDS.  One other quick thing.  I got dinged during code review when submitting something to the addon repo for calling xbmc.Monitor() over and over again.  The suggestion was to instantiate a global instance using something like:


KODIMONITOR = xbmc.Monitor()
KODIMONITOR.waitForAbort( 5 )
Leia Estuary mod: 333143 (thread)
Artist Slideshow: Add-on:Artist_Slideshow (wiki)
Audio Profiles: Add-on:Audio_Profiles (wiki)
SpeedFan Information Display: Add-on:SpeedFan_Information_Display (wiki)
Reply
#4
(2020-05-20, 07:15)pkscout Wrote: _daemonOne thing to look for is if there are any instances of xbmc.sleep(x).  That is a blocker, and the script won't exit until the sleep timer expires.  That can be replaced with xbmc.Monitor().waitForAbort(y).  There are two big differences.  First, waitForAbort will terminate as soon as an abort is requested.  Second, the parameter for waitForAbort is SECONDS, where as xbmc.sleep is in MILLISECONDS.  One other quick thing.  I got dinged during code review when submitting something to the addon repo for calling xbmc.Monitor() over and over again.  The suggestion was to instantiate a global instance using something like:


KODIMONITOR = xbmc.Monitor()
KODIMONITOR.waitForAbort( 5 )
Thanks.  One of the problem scripts is service.skin.widgets which I have forked and created a matrix / python 3 branch on my fork here:  python3 branch

This is without a commit to make the change to xbmc.abortRequested
It starts as a Kodi service and just creates an instance of Main class At the end of its __init__ it calls a _daemon method that runs in a while - else loop:  daemon waiting for Kodi to abort. It does do an xbmc.sleep(500) in the while loop.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix
Leia see: 304472
Reply
#5
I think I have the first one sorted.  I did need to add the waitForAbort method.  The structure of the module gives me fits as I am not comfortable with the scoping rules in Python and that caused me some grief.  The module is essentially a big class with an instance created when it is run.  The class does a bunch of things in its __init__ then calls its _daemon method until Kodi terminates it.   It looked like the best way to adapt the existing structure was to create an xbmc.Monitor() instance during the __init__ and use that.  But I was having trouble using that monitor instance due to it being out of scope.  I got it working finally via trial/error by using self.mymonitorinstance.method() but I don't really understand why that works and not just mymonitorinstance.method().

I'm also not sure how best to get the abort.  I take it the concept is to spend most time in the waitForAbort sleep and when the module "wakes up" do what needs to be done without looking for an abort, then go back to sleep.

scott s.
.
maintainer of skin  Aeon MQ5 mods for post-Gotham Kodi releases:
Matrix
Leia see: 304472
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
fixing xbmc.abortRequested00
This forum uses Lukasz Tkacz MyBB addons.