I can't get the built-in python callback method onAbortRequested for class xbmc.Monitor to work.
I've been testing several different version of a simple service that starts by initiating the xbmc.monitor class and then just sleeps waiting for an onAbortRequested events. The service starts ok but never receives an onAbortRequested when xbmc is stopping the service. I've been debugging this issue for several days now without success. Python interface tracing (ENABLE_TRACE_API) is enabled and python lib debugging enabled but haven't been able to actually nail this bastard. I'm getting lost somewhere near the RetardedAsynchCallbackHandler(!) and the callback queue. This is on current master, platform is osx.
Any idea what might be wrong and does anyone got a working example of onAbortRequested running as a service?
python service code, service.py
addon.xml
This is a part of the xbmc call path when initiating a service stop (inactivate button from the user interface). The python interface call path seems correct but the actual python method onAbortRequested is never called.
debug log for the stop activity:
debug log for the start activity:
I've been testing several different version of a simple service that starts by initiating the xbmc.monitor class and then just sleeps waiting for an onAbortRequested events. The service starts ok but never receives an onAbortRequested when xbmc is stopping the service. I've been debugging this issue for several days now without success. Python interface tracing (ENABLE_TRACE_API) is enabled and python lib debugging enabled but haven't been able to actually nail this bastard. I'm getting lost somewhere near the RetardedAsynchCallbackHandler(!) and the callback queue. This is on current master, platform is osx.
Any idea what might be wrong and does anyone got a working example of onAbortRequested running as a service?
python service code, service.py
Code:
import syst be
import time
import xbmc
class ExitMonitor(xbmc.Monitor):
def onAbortRequested(self):
print "ExitMonitor: onAbortRequested() -> sys.exit()"
sys.exit()
m = ExitMonitor()
print "Testing ExitMonitor, sleep(20000)..."
time.sleep(20000)
addon.xml
Code:
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<addon
id="service.exitmontor"
name="Exitmonitor test plugin"
provider-name="The Exitmonitor Team"
version="0.1.0">
<requires>
<import addon="xbmc.python" version="2.1.0" />
</requires>
<extension library="service.py" point="xbmc.service" start="startup">
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
<summary lang="en">Exitmonitor Addon Test</summary>
</extension>
</addon>
This is a part of the xbmc call path when initiating a service stop (inactivate button from the user interface). The python interface call path seems correct but the actual python method onAbortRequested is never called.
Code:
XBPython::StopScript() ->
XBPyThread::stop() -> g_pythonParser.OnAbortRequested(addon->ID())
XBPython::OnAbortRequested:(*it)->OnAbortRequested() ->
OnAbortRequested() { TRACE; invokeCallback(new CallbackFunction<Monitor>(this,&Monitor::onAbortRequested)); }
...
...
debug log for the stop activity:
Code:
00:23:17 T:2896765632 DEBUG: NEWADDON Entering bool XBPython::StopScript(const CStdString&)
00:23:17 T:2896765632 INFO: Stopping script with id: 1
00:23:24 T:2896765632 DEBUG: NEWADDON Entering void XBPython::OnAbortRequested(const CStdString&)
00:23:34 T:2896765632 DEBUG: NEWADDON Entering void XBMCAddon::xbmc::Monitor::OnAbortRequested()
00:23:38 T:2896765632 DEBUG: NEWADDON constructing CallbackFunction<M> 0xf435160
00:23:40 T:2896765632 DEBUG: NEWADDON Entering virtual void XBMCAddon::RetardedAsynchCallbackHandler::invokeCallback(XBMCAddon::Callback*)
00:23:43 T:2896765632 DEBUG: NEWADDON constructing AsynchCallbackMessage 0x5635b30
00:23:43 T:2896765632 DEBUG: NEWADDON Entering XBMCAddon::AsynchCallbackMessage::AsynchCallbackMessage(XBMCAddon::Callback*, XBMCAddon::RetardedAsynchCallbackHandler*)
00:23:43 T:2896765632 DEBUG: NEWADDON Leaving XBMCAddon::AsynchCallbackMessage::AsynchCallbackMessage(XBMCAddon::Callback*, XBMCAddon::RetardedAsynchCallbackHandler*)
00:23:43 T:2896765632 DEBUG: NEWADDON Leaving virtual void XBMCAddon::RetardedAsynchCallbackHandler::invokeCallback(XBMCAddon::Callback*)
00:23:43 T:2896765632 DEBUG: NEWADDON Leaving void XBMCAddon::xbmc::Monitor::OnAbortRequested()
00:23:43 T:2896765632 DEBUG: NEWADDON Leaving void XBPython::OnAbortRequested(const CStdString&)
00:23:48 T:2896765632 ERROR: XBPyThread::stop - script /Users/lars/Library/Application Support/XBMC/addons/service.exitmonitor/service.py didn't stop in 5 seconds - let's kill it
00:23:48 T:2896765632 DEBUG: NEWADDON Leaving bool XBPython::StopScript(const CStdString&)
00:23:48 T:2896765632 DEBUG: CGUIMediaWindow::GetDirectory (addons://enabled/xbmc.service)
00:23:48 T:2896765632 DEBUG: ParentPath = [addons://enabled/xbmc.service]
00:23:48 T:2954383360 NOTICE: Thread JobWorker start, auto delete: true
00:23:48 T:2954915840 NOTICE: Thread BackgroundLoader start, auto delete: false
00:23:48 T:2954915840 DEBUG: Thread BackgroundLoader 2954915840 terminating
00:24:18 T:2954383360 DEBUG: Thread JobWorker 2954383360 terminating (autodelete)
debug log for the start activity:
Code:
00:19:57 T:2956587008 DEBUG: NEWADDON Entering void XBPython::Initialize()
00:19:57 T:2956587008 INFO: initializing python engine.
00:19:57 T:2956587008 DEBUG: NEWADDON Leaving void XBPython::Initialize()
00:19:57 T:2956587008 DEBUG: new python thread created. id=1
00:19:57 T:2953850880 NOTICE: Thread XBPython start, auto delete: false
00:19:57 T:2953850880 DEBUG: Python thread: start processing
00:20:41 T:2953850880 DEBUG: NEWADDON constructing Python::LanguageHook 0xf297c10
00:20:41 T:2953850880 DEBUG: NEWADDON Entering void XBMCAddon::Python::LanguageHook::RegisterMe()
00:20:41 T:2953850880 DEBUG: NEWADDON Leaving void XBMCAddon::Python::LanguageHook::RegisterMe()
00:20:41 T:2953850880 DEBUG: NEWADDON Entering void XBPython::InitializeInterpreter(ADDON::AddonPtr)
00:20:41 T:2953850880 DEBUG: NEWADDON Entering PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:20:41 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:41 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:41 T:2953850880 DEBUG: NEWADDON Entering static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:41 T:2953850880 DEBUG: NEWADDON Leaving static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:44 T:2953850880 NOTICE: -->Python Interpreter Initialized<--
00:20:44 T:2953850880 DEBUG: NEWADDON Leaving PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:20:44 T:2896765632 DEBUG: WinSystemOSX: Fullscreen window Xcode obscures XBMC!
00:20:44 T:2953850880 DEBUG: NEWADDON Entering PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:20:44 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:44 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:44 T:2953850880 DEBUG: NEWADDON Entering static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:44 T:2953850880 DEBUG: NEWADDON Leaving static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:45 T:2953850880 DEBUG: NEWADDON Leaving PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:20:45 T:2953850880 DEBUG: NEWADDON Leaving void XBPython::InitializeInterpreter(ADDON::AddonPtr)
00:20:45 T:2953850880 DEBUG: Process - The source file to load is /Users/lars/Library/Application Support/XBMC/addons/service.exitmonitor/service.py
00:20:45 T:2953850880 DEBUG: Process - Setting the Python path to /Users/lars/Library/Application Support/XBMC/addons/service.exitmonitor:/Users/lars/Library/Application Support/XBMC/addons/weather.wunderground/resources/lib/wunderground:/Users/lars/Library/Application Support/XBMC/addons/script.module.simplejson/lib:/Users/lars/Library/Application Support/XBMC/addons/script.module.beautifulsoup/lib:/Users/lars/src/xbmc/xbmc-ffmpeg-version-bump/addons/script.module.pil/lib:/Users/lars/Library/Application Support/XBMC/addons/script.module.buggalo/lib:/Users/lars/Library/Application Support/XBMC/addons/script.module.mechanize/lib:/Users/lars/Library/Application Support/XBMC/addons/script.module.parsedom/lib:/Users/lars/Library/Application Support/XBMC/addons/script.module.elementtree/lib:/Users/lars/src/xbmc/xbmc-ffmpeg-version-bump/addons/script.module.pysqlite/lib:/Users/lars/Library/Application Support/XBMC/addons/service.exitmonitor/lib:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python26.zip:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/plat-darwin:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/plat-mac:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/plat-mac/lib-scriptpackages:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/lib-tk:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/lib-old:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/lib-dynload:/Users/Shared/xbmc-depends/macosx10.8_i386-target/lib/python2.6/site-packages:
00:20:45 T:2953850880 DEBUG: Process - Entering source directory /Users/lars/Library/Application Support/XBMC/addons/service.exitmonitor
00:20:45 T:2953850880 DEBUG: Instantiating addon using automatically obtained id of "service.exitmontor" dependent on version 2.1.0 of the xbmc.python api
00:20:48 T:2953850880 DEBUG: NEWADDON Entering PyObject* PythonBindings::xbmc_XBMCAddon_xbmc_Monitor_New(PyTypeObject*, PyObject*, PyObject*)
00:20:52 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:52 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:20:52 T:2953850880 DEBUG: NEWADDON Entering static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:52 T:2953850880 DEBUG: NEWADDON Leaving static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:20:52 T:2954383360 NOTICE: Thread BackgroundLoader start, auto delete: false
00:20:52 T:2954383360 DEBUG: Thread BackgroundLoader 2954383360 terminating
00:21:01 T:2953850880 DEBUG: NEWADDON constructing Monitor 0xf437560
00:21:01 T:2953850880 DEBUG: NEWADDON Entering virtual XBMCAddon::CallbackHandler* XBMCAddon::Python::LanguageHook::GetCallbackHandler()
00:21:02 T:2953850880 DEBUG: NEWADDON constructing PythonCallbackHandler 0xf468490
00:21:02 T:2953850880 DEBUG: NEWADDON Entering XBMCAddon::Python::PythonCallbackHandler::PythonCallbackHandler()
00:21:02 T:2953850880 DEBUG: NEWADDON Leaving XBMCAddon::Python::PythonCallbackHandler::PythonCallbackHandler()
00:21:02 T:2953850880 DEBUG: NEWADDON Leaving virtual XBMCAddon::CallbackHandler* XBMCAddon::Python::LanguageHook::GetCallbackHandler()
00:21:04 T:2953850880 DEBUG: NEWADDON Entering virtual XBMCAddon::String XBMCAddon::Python::LanguageHook::GetAddonId()
00:21:04 T:2953850880 DEBUG: NEWADDON Leaving virtual XBMCAddon::String XBMCAddon::Python::LanguageHook::GetAddonId()
00:21:06 T:2953850880 DEBUG: NEWADDON Entering virtual void XBMCAddon::Python::LanguageHook::RegisterMonitorCallback(XBMCAddon::xbmc::Monitor*)
00:21:06 T:2953850880 DEBUG: NEWADDON Entering void XBPython::RegisterPythonMonitorCallBack(XBMCAddon::xbmc::Monitor*)
00:21:10 T:2953850880 DEBUG: NEWADDON Leaving void XBPython::RegisterPythonMonitorCallBack(XBMCAddon::xbmc::Monitor*)
00:21:12 T:2953850880 DEBUG: NEWADDON Leaving virtual void XBMCAddon::Python::LanguageHook::RegisterMonitorCallback(XBMCAddon::xbmc::Monitor*)
00:21:18 T:2956587008 DEBUG: Thread JobWorker 2956587008 terminating (autodelete)
00:21:18 T:2953850880 DEBUG: NEWADDON Entering void PythonBindings::prepareForReturn(XBMCAddon::AddonClass*)
00:21:18 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:18 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:18 T:2953850880 DEBUG: NEWADDON Entering void XBMCAddon::Python::LanguageHook::RegisterAddonClassInstance(XBMCAddon::AddonClass*)
00:21:21 T:2953850880 DEBUG: NEWADDON Leaving void XBMCAddon::Python::LanguageHook::RegisterAddonClassInstance(XBMCAddon::AddonClass*)
00:21:21 T:2953850880 DEBUG: NEWADDON Leaving void PythonBindings::prepareForReturn(XBMCAddon::AddonClass*)
00:21:28 T:2953850880 DEBUG: NEWADDON Leaving PyObject* PythonBindings::xbmc_XBMCAddon_xbmc_Monitor_New(PyTypeObject*, PyObject*, PyObject*)
00:21:28 T:2953850880 DEBUG: NEWADDON Entering PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:21:28 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:28 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:28 T:2953850880 DEBUG: NEWADDON Entering static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:21:28 T:2953850880 DEBUG: NEWADDON Leaving static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:21:32 T:2953850880 NOTICE: Testing ExitMonitor, sleep(20000)...
00:21:32 T:2953850880 DEBUG: NEWADDON Leaving PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:21:32 T:2953850880 DEBUG: NEWADDON Entering PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)
00:21:32 T:2953850880 DEBUG: NEWADDON Entering static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:32 T:2953850880 DEBUG: NEWADDON Leaving static XBMCAddon::AddonClass::Ref<XBMCAddon::Python::LanguageHook> XBMCAddon::Python::LanguageHook::GetIfExists(PyInterpreterState*)
00:21:32 T:2953850880 DEBUG: NEWADDON Entering static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:21:32 T:2953850880 DEBUG: NEWADDON Leaving static void XBMCAddon::LanguageHook::SetLanguageHook(XBMCAddon::LanguageHook*)
00:21:34 T:2953850880 DEBUG: NEWADDON Leaving PyObject* PythonBindings::xbmc_log(PyObject*, PyObject*, PyObject*)