Commit ae488ce3 authored by Stefan Behnel's avatar Stefan Behnel

Write regular time stamps into the test log to spot slow running tests.

parent 51c1f8fe
...@@ -17,6 +17,7 @@ import traceback ...@@ -17,6 +17,7 @@ import traceback
import warnings import warnings
import zlib import zlib
import glob import glob
from contextlib import contextmanager
try: try:
import platform import platform
...@@ -2042,6 +2043,8 @@ def main(): ...@@ -2042,6 +2043,8 @@ def main():
pool = multiprocessing.Pool(options.shard_count) pool = multiprocessing.Pool(options.shard_count)
tasks = [(options, cmd_args, shard_num) for shard_num in range(options.shard_count)] tasks = [(options, cmd_args, shard_num) for shard_num in range(options.shard_count)]
errors = [] errors = []
# NOTE: create process pool before time stamper thread to avoid forking issues.
with time_stamper_thread():
for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks): for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks):
if return_code != 0: if return_code != 0:
errors.append(shard_num) errors.append(shard_num)
...@@ -2055,6 +2058,7 @@ def main(): ...@@ -2055,6 +2058,7 @@ def main():
else: else:
return_code = 0 return_code = 0
else: else:
with time_stamper_thread():
_, return_code = runtests(options, cmd_args, coverage) _, return_code = runtests(options, cmd_args, coverage)
print("ALL DONE") print("ALL DONE")
...@@ -2067,6 +2071,42 @@ def main(): ...@@ -2067,6 +2071,42 @@ def main():
sys.exit(return_code) sys.exit(return_code)
@contextmanager
def time_stamper_thread(interval=10):
"""
Print regular time stamps into the build logs to find slow tests.
@param interval: time interval in seconds
"""
try:
_xrange = xrange
except NameError:
_xrange = range
import threading
from datetime import datetime
from time import sleep
interval = _xrange(interval * 4)
now = datetime.now
stop = False
def time_stamper():
while True:
for _ in interval:
if stop:
return
sleep(1./4)
print('\n#### %s' % now())
thread = threading.Thread(target=time_stamper)
thread.start()
try:
yield
finally:
stop = True
thread.join()
def configure_cython(options): def configure_cython(options):
global CompilationOptions, pyrex_default_options, cython_compile global CompilationOptions, pyrex_default_options, cython_compile
from Cython.Compiler.Main import \ from Cython.Compiler.Main import \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment