mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add a 10 minute timeout to individual tests.
On the bots, we have a timeout without output of 60 minutes for the entire test. This should ensure that we are able to kill mis-behaving tests and give a good error instead of just getting a jenkins timeout error. For those confused, this is for the guard malloc/leaks test. rdar://36874229
This commit is contained in:
@@ -57,6 +57,24 @@ class Result(object):
|
||||
print(fmt.format(self.get_name(), self.get_result()))
|
||||
|
||||
|
||||
def run_with_timeout(func, args):
|
||||
# We timeout after 10 minutes.
|
||||
timeout_seconds = 10 * 60
|
||||
|
||||
# We just use this to create a timeout since we use an older python. Once
|
||||
# we update to use python >= 3.3, use the timeout API on communicate
|
||||
# instead.
|
||||
import multiprocessing.dummy
|
||||
fakeThreadPool = multiprocessing.dummy.Pool(1)
|
||||
try:
|
||||
result = fakeThreadPool.apply_async(func, args=args)
|
||||
return result.get(timeout_seconds)
|
||||
except multiprocessing.TimeoutError:
|
||||
fakeThreadPool.terminate()
|
||||
raise RuntimeError("Child process aborted due to timeout. "
|
||||
"Timeout: %s seconds" % timeout_seconds)
|
||||
|
||||
|
||||
def _unwrap_self(args):
|
||||
return type(args[0]).process_input(*args)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user