Commit b07ee506 authored by Stefan Behnel's avatar Stefan Behnel

Simplify code in time stamper thread and make sure the dup-ed stderr is closed in the end.

parent 2c0d0882
......@@ -2209,6 +2209,11 @@ def time_stamper_thread(interval=10):
Print regular time stamps into the build logs to find slow tests.
@param interval: time interval in seconds
"""
if not interval or interval < 0:
# Do nothing
yield
return
try:
_xrange = xrange
except NameError:
......@@ -2218,18 +2223,15 @@ def time_stamper_thread(interval=10):
import datetime
from time import sleep
if not interval or interval < 0:
# Do nothing
yield
else:
interval = _xrange(interval * 4)
now = datetime.datetime.now
stop = False
# We capture stderr in some places.
# => make sure we write to the real (original) stderr of the test runner.
def write(s, stderr=os.dup(2)):
os.write(stderr, s if IS_PY2 else s.encode('ascii'))
stderr = os.dup(2)
def write(s):
os.write(stderr, s if type(s) is bytes else s.encode('ascii'))
def time_stamper():
while True:
......@@ -2247,6 +2249,7 @@ def time_stamper_thread(interval=10):
finally:
stop = True
thread.join()
os.close(stderr)
def configure_cython(options):
......
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