|
@@ -18,7 +18,7 @@ from .config import PYTHON_BINARY, OUTPUT_PERMISSIONS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-def run(*args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs):
|
|
|
|
|
|
|
+def run(cmd, *args, input=None, capture_output=True, timeout=None, check=False, text=False, start_new_session=True, **kwargs):
|
|
|
"""Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective
|
|
"""Patched of subprocess.run to kill forked child subprocesses and fix blocking io making timeout=innefective
|
|
|
Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
|
|
Mostly copied from https://github.com/python/cpython/blob/master/Lib/subprocess.py
|
|
|
"""
|
|
"""
|
|
@@ -37,10 +37,10 @@ def run(*args, input=None, capture_output=True, timeout=None, check=False, text=
|
|
|
|
|
|
|
|
pgid = None
|
|
pgid = None
|
|
|
try:
|
|
try:
|
|
|
- if args[0].endswith('.py'):
|
|
|
|
|
- args = (PYTHON_BINARY, *args)
|
|
|
|
|
|
|
+ if isinstance(cmd, (list, tuple)) and cmd[0].endswith('.py'):
|
|
|
|
|
+ cmd = (PYTHON_BINARY, *cmd)
|
|
|
|
|
|
|
|
- with Popen(*args, start_new_session=start_new_session, **kwargs) as process:
|
|
|
|
|
|
|
+ with Popen(cmd, *args, start_new_session=start_new_session, **kwargs) as process:
|
|
|
pgid = os.getpgid(process.pid)
|
|
pgid = os.getpgid(process.pid)
|
|
|
try:
|
|
try:
|
|
|
stdout, stderr = process.communicate(input, timeout=timeout)
|
|
stdout, stderr = process.communicate(input, timeout=timeout)
|