Quick question on multiprocessing
#1
Hello, I would like to know if XBMC Python supports multiprocessing in general. I tried to do some coding by creating a new thread in a python crypts for an addon. But XBMC doesn't seem to get it. Which is weird because this basic code works in IDLE.

Does XBMC simply block new threads for whatever reason (like avoid creating zombie threads)?
Reply
#2
uh, no. threads are fine. forks i've been told have some issues on some platforms.
Reply
#3
okay thank you
Reply
#4
Follow up question to an old thread:

So am I correct in assuming Python's multiprocessing module cannot be used for plugins? I assume the multiprocessing.Process call is using the OS's fork call to create processes?

I'm asking because I've ran into behavior where it works on mac OS, but not on Windows. The code in question executes a process, but I don't think any new processes are ever created. Perhaps it's because XBMC doesn't support multiprocessing.

Sample code:
Code:
from multiprocessing import Process
...
proc = Process(target=ProcessTarget, args=(filePath, language))

Full code available on request.
Reply
#5
DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far ... (See xkcd #979)

XBMC on Windows does not like the following (multiprocessing module):
Code:
Process(target=ProcessTarget, args=(filePath, language))

And XBMC on Mac OS does not like this (subprocess module):
Code:
subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)

Tested on XBMC Eden only. Good luck!
Reply
#6
Thanks for posting this.

I wonder if this still holds true in kodi17.

off to threading for me...
Reply
#7
multiprocessing and subprocess modules serve different purposes.

Yes, multiprocessing can be used in Kodi, but you need to take into account all possible pitfalls. For example, on Windows the module where you use multiprocessing must be importable without side-effects. And all data passed to child processes must be picklable. Also multiprocessing.Manager is broken on Widows.

All this makes multiprocessing tricky to use, so for IO-bound tasks or tasks with C-API calls (including time.sleep which releases the GIL for the duration of sleeping) it's better to use multithreading.
Reply
#8
Multiprocessing is not available on android platforms I have used. Anything I had using this module had to be changed to the threading module.

No issues on Windows for me. But as you can see from the other replies, it is not the best option for multi platform Support imo.
Reply

Logout Mark Read Team Forum Stats Members Help
Quick question on multiprocessing0