Embedded Python and multiprocessing on Windows?

Apple applemask at gmail.com
Thu Aug 9 12:09:22 EDT 2018


I've been working on a project involving embedding Python into a Windows application. I've got all of that working fine on the C++ side, but the script side seems to be hitting a dead end with multiprocessing. When my script tries to run the same multiprocessing code that works in a non-embedded environment, the code doesn't appear to be executed at all.

A StackOverflow thread gave me a few ideas to try out, so I gave it a shot with these lines added:

sys.argv = ['C:\\path\\to\\script.py']
mp.set_executable("C:\\Python37\\python.exe")
p = mp.Process(target=somefunction)
p.start()

Still no joy. However, a Python.exe window does pop up for a tenth of a second, so *something* is happening.

So does multiprocessing actually work in embedded Python, or am I at a dead end here? My guess is that it's probably linked to Windows not having fork, so the combination of being embedded and having to spawn is making things go goofy.



More information about the Python-list mailing list