Last active
February 3, 2022 09:51
-
-
Save urigoren/5db3152aed17922c3087ed3cceb74dd9 to your computer and use it in GitHub Desktop.
Run a python process in the background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import subprocess, sys | |
def bgprocess(p:Path, *args): | |
python = sys.executable | |
if not isinstance(p, Path): | |
p = Path(p) | |
p = p.absolute() | |
return subprocess.Popen([python, p.name]+list(args), cwd = str(p.parent), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment