Skip to content

Commit 8ce61a3

Browse files
pipcl.py: run(): added <timeout> arg.
1 parent b04e8b2 commit 8ce61a3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

pipcl.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,16 @@ def git_items( directory, submodules=False):
18991899
return ret
19001900

19011901

1902-
def run( command, capture=False, check=1, verbose=1, env_extra=None, caller=1):
1902+
def run(
1903+
command,
1904+
*,
1905+
capture=False,
1906+
check=1,
1907+
verbose=1,
1908+
env_extra=None,
1909+
timeout=None,
1910+
caller=1,
1911+
):
19031912
'''
19041913
Runs a command using `subprocess.run()`.
19051914
@@ -1923,6 +1932,10 @@ def run( command, capture=False, check=1, verbose=1, env_extra=None, caller=1):
19231932
If true we show the command.
19241933
env_extra:
19251934
None or dict to add to environ.
1935+
timeout:
1936+
If not None, timeout in seconds; passed directly to
1937+
subprocess.run(). Note that on MacOS subprocess.run() seems to
1938+
leave processes running if timeout expires.
19261939
Returns:
19271940
check capture Return
19281941
--------------------------
@@ -1949,6 +1962,7 @@ def run( command, capture=False, check=1, verbose=1, env_extra=None, caller=1):
19491962
check=check,
19501963
encoding='utf8',
19511964
env=env,
1965+
timeout=timeout,
19521966
)
19531967
if check:
19541968
return cp.stdout if capture else None

0 commit comments

Comments
 (0)