oh look, another multiprocess thread again :spin::spin::spin:
It must be this time of the year again!
Basically I want to reset the python sys.excecutable to be the installed python installation source platform independently.
Mainly to launch multiprocess without wasting too time on forking around.
So i present a example which I blasted together:
from subprocess import Popen,PIPE commands = [ ["which", "python3", "python"], ["where", "python3", "python"], ] def is_correct_excecutable(thing): return 'python' in thing.lower() and ('/' in thing or '\\' in thing) def find_python_excecutable(): for command in commands: try: with Popen(command, stdout=PIPE) as proc: path = proc.stdout.read().decode().strip() if is_correct_excecutable(path): return path except Exception as e: print(e) excecutable = find_python_excecutable() print(excecutable) import sys sys.executable = excecutable from multiprocessing import Process import os def f(name): import time for i in range(1000): print('hello', name, time.time()) time.sleep(0.5) def main(): p = Process(target=f, args=('bob',)) p.start()
And the questions are:
Is this the easiest way?
I don’t know if the python installed with in Blender is easy to find on all platforms.
Is it right to expect that most folks in BA forum have installed python on their machine?