fix python file execution checking
This commit is contained in:
parent
3d40693f1c
commit
c3d009e4ec
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
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
|
||||
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)
|
||||
try:
|
||||
stdout, stderr = process.communicate(input, timeout=timeout)
|
||||
|
|
Loading…
Reference in a new issue