Only one python intepreter/thread at a time?
#1
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
16:15:37 T:18248   DEBUG: CApplication::ExecuteXBMCAction : Translating Close
16:15:37 T:18248   DEBUG: CApplication::ExecuteXBMCAction : To Close
16:15:37 T:18248   DEBUG: CApplication::ExecuteXBMCAction : Translating XBMC.RunScript($INFO[Skin.String(SubtitleScript_Path)])
16:15:37 T:18248   DEBUG: CApplication::ExecuteXBMCAction : To XBMC.RunScript(script.xbmc.subtitles)
16:15:37 T:18248    INFO: initializing python engine.
16:15:37 T:18248   DEBUG: new python thread created. id=41
16:15:37 T:20384  NOTICE: Thread XBPyThread start, auto delete: false
16:15:37 T:20384   DEBUG: Python thread: start processing

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
16:16:31 T:19664  NOTICE: ===== PLEXBMC STOP =====
16:16:31 T:19664    INFO: Scriptresult: Success
16:16:31 T:19664    INFO: Python script stopped
16:16:31 T:19664   DEBUG: Thread XBPyThread 19664 terminating
16:16:31 T:18248   DEBUG: waiting for python thread 39 (C:\Users\dave\AppData\Roaming\XBMC\addons\plugin.video.plexbmc\default.py) to stop
16:16:31 T:18248   DEBUG: python thread 39 (C:\Users\dave\AppData\Roaming\XBMC\addons\plugin.video.plexbmc\default.py) destructed
16:16:31 T:20320  NOTICE: -->Python Interpreter Initialized<--
16:16:31 T:20320   DEBUG: XBPyThread::Process - The source file to load is C:\Users\dave\AppData\Roaming\XBMC\addons\script.xbmc.subtitles\default.py

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
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply
#2
http://trac.xbmc.org/ticket/14212
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#3
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.
Reply
#4
i think it is related (or remotely) hence i linked the ticket
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#5
Yes, I do run a while loop, with a time.sleep(5):

Code:
while xbmc.Player().isPlaying():
        #Get the current playback time

       #....Do some stuff.....

        time.sleep(5)

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.
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply
#6
i'd say add your findings to it then Smile
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#7
Thanks - will do.

Don;t supposed you can think of another way of do this (monitoring playback progress?)
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply
#8
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
Reply
#9
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?
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply
#10
Here's what I'm currently using: https://github.com/bstrdsmkr/1Channel/bl...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
Reply
#11
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).
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply
#12
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
Reply
#13
That's great - thanks. I'll look to add something similar to get around this problem.
Add-on:PleXBMC (wiki) - Play Plex media through XBMC
PleXBMC Helper - Integrate Official/Unoffical Plex remote control apps into PleXBMC
PleXBMC Repository - install and manage all PleXBMC addons
Quartz3 PleXBMC - Integrate PleXBMC into home menus
Reply

Logout Mark Read Team Forum Stats Members Help
Only one python intepreter/thread at a time?0