Kodi Community Forum

Full Version: xbmc.Monitor abortRequested waitForAbort why works only on service instance?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I came across something in the past that i thought worked

on service side to check if kodi request an abort action (e.g. to Kodi close)
you can use example:

python:

monitor = xbmc.Monitor()
while not monitor.abortRequested():
   if monitor.waitForAbort(1):
       break

then you can stop your looped code.

But if you try to use same code on an add-on instance or script instance
the methods abortRequested, waitForAbort not works at all

I found only the solution to encaplusate the Monitor interface to a python class,
and verify the onNotification events to check when kodi will be terminated:

python:

def onNotification(self, sender, method, data):
    if method in ['System.OnQuit', 'System.OnRestart', 'System.OnSleep']:
        self.is_abort_requested = True

are there or will there be better solutions?
I use basically the same example you say isn’t working in Artist Slideshow with no problems.
Try this addon test:
http://www.mediafire.com/file/qflumstj8j...n.zip/file

Run the add-on then
when loading window is on screen close Kodi without using a "back" key on loading screen

so then you can use example:
json rpc
Code:
curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://192.168.2.2:8080/jsonrpc --user kodi:kodi

or if you are on window try close the kodi window with "X" button

or you can also open the "Shutdown menu" and do Exit

then you can see that the loop code not exit and Kodi is in a freeze state (see task manager)
that will never be terminated
(2020-07-20, 08:51)CastagnaIT Wrote: [ -> ]Try this addon test:
http://www.mediafire.com/file/qflumstj8j...n.zip/file

Run the add-on then
when loading window is on screen close Kodi without using a "back" key on loading screen

so then you can use example:
json rpc
Code:
curl -s --data-binary '{"jsonrpc": "2.0", "method": "Application.Quit", "id":1}' -H 'content-type: application/json;' http://192.168.2.2:8080/jsonrpc --user kodi:kodi

or if you are on window try close the kodi window with "X" button

or you can also open the "Shutdown menu" and do Exit

then you can see that the loop code not exit and Kodi is in a freeze state (see task manager)
that will never be terminated

Did you ever find a solution for this?

/stride
this problem has been already solved on Kodi 19
(2022-04-27, 08:00)CastagnaIT Wrote: [ -> ]this problem has been already solved on Kodi 19

Hmmm is it possible the python interpreter is stateful across Kodi reboots?
Fighting with some asyncio in there and getting these when reporting exceptions:

ERROR <general>: ASYNCIO exception: There is no current event loop in thread 'Dummy-4'.
After Kodi restart:
ERROR <general>: ASYNCIO exception: There is no current event loop in thread 'Dummy-4'.

Could this be interpretor #4?
no here we are talkin about of abortRequested internal kodi behaviour only
asyncio is in python core
(2022-04-27, 14:03)CastagnaIT Wrote: [ -> ]no here we are talkin about of abortRequested internal kodi behaviour only
asyncio is in python core

Doing some testing over here, https://github.com/x-stride/kodi-addons-async

Slowly getting somewhere 🙂
Omg... Some forum-post editors and tablet keyboards really do not work well together!

Typos fixed, I hope.