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,11 +2043,13 @@ def main(): ...@@ -2042,11 +2043,13 @@ 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 = []
for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks): # NOTE: create process pool before time stamper thread to avoid forking issues.
if return_code != 0: with time_stamper_thread():
errors.append(shard_num) for shard_num, return_code in pool.imap_unordered(runtests_callback, tasks):
print("FAILED (%s/%s)" % (shard_num, options.shard_count)) if return_code != 0:
print("ALL DONE (%s/%s)" % (shard_num, options.shard_count)) errors.append(shard_num)
print("FAILED (%s/%s)" % (shard_num, options.shard_count))
print("ALL DONE (%s/%s)" % (shard_num, options.shard_count))
pool.close() pool.close()
pool.join() pool.join()
if errors: if errors:
...@@ -2055,7 +2058,8 @@ def main(): ...@@ -2055,7 +2058,8 @@ def main():
else: else:
return_code = 0 return_code = 0
else: else:
_, return_code = runtests(options, cmd_args, coverage) with time_stamper_thread():
_, return_code = runtests(options, cmd_args, coverage)
print("ALL DONE") print("ALL DONE")
try: try:
...@@ -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