13 lines
365 B
Python
13 lines
365 B
Python
from threading import Thread
|
|
import subprocess
|
|
from typing import Callable
|
|
|
|
def nonblocking_run(args: list[str], when_done: Callable[[], None]) -> subprocess.Popen:
|
|
def _run(process: subprocess.Popen):
|
|
process.wait()
|
|
when_done()
|
|
|
|
process = subprocess.Popen(args)
|
|
t = Thread(target=_run, args=(process,))
|
|
t.start()
|
|
return process |