@@ -143,6 +143,12 @@ def set_swift_branch(branch):
143
143
swift_branch = branch
144
144
145
145
146
+ def set_default_execute_timeout (timeout ):
147
+ """Override the default execute timeout"""
148
+ global DEFAULT_EXECUTE_TIMEOUT
149
+ DEFAULT_EXECUTE_TIMEOUT = timeout
150
+
151
+
146
152
def clone_repos ():
147
153
"""Clone Swift and dependencies in parallel.
148
154
@@ -299,14 +305,16 @@ def __str__(self):
299
305
self .returncode ))
300
306
301
307
302
- def execute (command , timeout = DEFAULT_EXECUTE_TIMEOUT ,
308
+ def execute (command , timeout = None ,
303
309
stdout = sys .stdout , stderr = sys .stderr ,
304
310
** kwargs ):
305
311
"""Execute a given command with an optional timeout in seconds.
306
312
307
313
>>> execute(['echo', 'Hello, World!'])
308
314
0
309
315
"""
316
+ if timeout is None :
317
+ timeout = DEFAULT_EXECUTE_TIMEOUT
310
318
shell_debug_print (command , stderr = stderr )
311
319
returncode = 124 # timeout return code
312
320
try :
@@ -320,13 +328,15 @@ def execute(command, timeout=DEFAULT_EXECUTE_TIMEOUT,
320
328
return returncode
321
329
322
330
323
- def check_execute_output (command , timeout = DEFAULT_EXECUTE_TIMEOUT ,
331
+ def check_execute_output (command , timeout = None ,
324
332
stdout = sys .stdout , stderr = sys .stderr , ** kwargs ):
325
333
"""Check execute a given command and return its output.
326
334
327
335
>>> check_execute_output(['echo', 'Hello, World!'])
328
336
'Hello, World!\\ n'
329
337
"""
338
+ if timeout is None :
339
+ timeout = DEFAULT_EXECUTE_TIMEOUT
330
340
shell_debug_print (command , stderr = stderr )
331
341
try :
332
342
with Timeout (timeout ):
@@ -339,7 +349,7 @@ def check_execute_output(command, timeout=DEFAULT_EXECUTE_TIMEOUT,
339
349
return output
340
350
341
351
342
- def check_execute (command , timeout = DEFAULT_EXECUTE_TIMEOUT ,
352
+ def check_execute (command , timeout = None ,
343
353
sandbox_profile = None , max_retries = 1 ,
344
354
stdout = sys .stdout , stderr = sys .stderr ,
345
355
** kwargs ):
@@ -348,6 +358,8 @@ def check_execute(command, timeout=DEFAULT_EXECUTE_TIMEOUT,
348
358
>>> check_execute(['echo', 'Hello, World!'])
349
359
0
350
360
"""
361
+ if timeout is None :
362
+ timeout = DEFAULT_EXECUTE_TIMEOUT
351
363
if sandbox_profile :
352
364
if platform .system () == 'Darwin' :
353
365
command = ['sandbox-exec' , '-f' , sandbox_profile ] + command
0 commit comments