How to run another Python program without holding up original [duplicate] How to run another Python program without holding up original [duplicate] python python

How to run another Python program without holding up original [duplicate]


Use subprocess:

import subprocess#codeprog = subprocess.Popen(['python', filename, args])#more code


If the other Python program is importable, and the functionality you need can be called via a function, then it is preferable to use multiprocessing instead of subprocess, since the arguments can be passed as Python objects, instead of via strings:

import somescriptimport multiprocessing as mpproc = mp.Process(target=somescript.main, args=...)proc.start()