Only one python intepreter/thread at a time? - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: Only one python intepreter/thread at a time? (/showthread.php?tid=163638) |
Only one python intepreter/thread at a time? - hippojay - 2013-04-29 Hi, Does XBMC only allow a single instance of python to run at any one time? My addon starts media playback, then sits in the background and monitors the playback time, sending the data back to another target. If I then attempt to start the xbmc subtitle service, it will sit there waiting until I stop backplay (and therefore my addon stops running too). I can see that XBMC starts the process of running the subtitle script: Code: 16:15:37 T:18248 DEBUG: CApplication::ProcessMouse: trying mouse action leftclick but never runs it until I close my addon (I've edited the subtitle script to troubleshoot, so I know it definitely doesn't run the script at all): Code: 16:16:31 T:19664 NOTICE: PleXBMC -> monitorPlayback: Playback Stopped I've not checked previous revisions yet, but this has only been reported that this has stopped working recently, so I'm guessing it's introduced in 12/12.1 Full debug log: http://pastebin.com/UqBjt5sG RE: Only one python intepreter/thread at a time? - Martijn - 2013-04-29 http://trac.xbmc.org/ticket/14212 RE: Only one python intepreter/thread at a time? - Bstrdsmkr - 2013-04-29 Possibly related to the op, but not the bug above, if the while loop in your service isn't calling Xbmc.sleep() and its just looping, it will block, even other services stated before it. RE: Only one python intepreter/thread at a time? - Martijn - 2013-04-29 i think it is related (or remotely) hence i linked the ticket RE: Only one python intepreter/thread at a time? - hippojay - 2013-04-29 Yes, I do run a while loop, with a time.sleep(5): Code: while xbmc.Player().isPlaying(): I changed the time.sleep(5) for an xbmc.sleep(5000) and this had no effect. Looking at this ticket, whist I'm not using xbmcvfs, the result is exactly the same. RE: Only one python intepreter/thread at a time? - Martijn - 2013-04-29 i'd say add your findings to it then RE: Only one python intepreter/thread at a time? - hippojay - 2013-04-29 Thanks - will do. Don;t supposed you can think of another way of do this (monitoring playback progress?) RE: Only one python intepreter/thread at a time? - Bstrdsmkr - 2013-04-29 This works for me: 1. In onPlayBackStarted, set a class property to True. 2. In onPlayBackEnded and onPlaybackStopped, set the property to False 3. The service loops while the property is True, and not xbmc.abortRequested() 4. I also have an outer loops that runs while not xbmc.abortRequested() to keep things alive while the property is False. (Truthfully, it's also checking other stuff, but it's unrelated to this) Let me know if that doesn't make sense or you need a code sample RE: Only one python intepreter/thread at a time? - hippojay - 2013-04-30 Thanks - could you let me have a code sample, as I tried looping on True and this caused the same issue. Also - I've been testing on some other platforms and only Linux and Windows exhibit this issue. On OSX everything works as normal, so i'm not sure if you are testing this on on OSX machine? RE: Only one python intepreter/thread at a time? - Bstrdsmkr - 2013-04-30 Here's what I'm currently using: https://github.com/bstrdsmkr/1Channel/blob/master/service.py I'm not kicking off any other add-ons from the loop so that might not work for you exactly, but maybe it'll help. That's how I'm tracking playback progress RE: Only one python intepreter/thread at a time? - hippojay - 2013-05-01 Thanks - I see what you've done. Also - I didn't realise an addon could be defined as a plugin [b]and[/]b a service - which was what confused me. I take it that this approach is pretty stable and you don't get missed tracking or incorrect tracking? I didn't really want to have to farm out the tracking process to a separate service, as there are going to be more problems with resetting values and passing variables (which you have more control over in a plugin loop). RE: Only one python intepreter/thread at a time? - Bstrdsmkr - 2013-05-01 Yeah it's pretty handy. Just make sure to define the one you want it to show up as first in addon.xml I haven't missed any yet and haven't had any reports from users so AFAICT, it's rock solid RE: Only one python intepreter/thread at a time? - hippojay - 2013-05-01 That's great - thanks. I'll look to add something similar to get around this problem. |