2019-03-24, 22:22
My screensaver script has numerous threads and uses several Monitor subclasses. After some testing it appears that your code won't receive a Monitor.onNotification unless xbmc.sleep/xbmc.waitForAbort is called from the same thread that the Monitor was instantiated from. I also noticed that if I had multiple monitors I could get the same notification as soon as each thread called xbmc.sleep. I have tried to find where this behavior has been documented without any success. Is this a well-known behavior?
Also, while I try to have the code call xbmc.waitForAbort whenever a wait/sleep is needed, you can not avoid using Python waits as well. For situations where a long wait is possible, I try to use threading.Event, and then when an Abort occurs, call threading.Event().set() so that anything waiting are aborted early.
If the monitoring is behaving as I believe, then I think I will change to have the main thread to:
Frank
Also, while I try to have the code call xbmc.waitForAbort whenever a wait/sleep is needed, you can not avoid using Python waits as well. For situations where a long wait is possible, I try to use threading.Event, and then when an Abort occurs, call threading.Event().set() so that anything waiting are aborted early.
If the monitoring is behaving as I believe, then I think I will change to have the main thread to:
- Own all of the monitors
- Be pretty simple
- Spend most of it's time sleeping
- Any expensive operations will be spun off onto independent threads.
- Is there a single thread to notify all plugins of a monitored event?
- How important is it to avoid taking too long to process some notification from Kodi?
Frank