Skip to content

Commit 4ff1e34

Browse files
committed
Revert [lit] Synthesize artificial deadline
Python on Windows raises this OverflowError: gotit = waiter.acquire(True, timeout) OverflowError: timestamp too large to convert to C _PyTime_t So it seems this API behave the same way on every OS. Also reverts the dependent commit a660dc5. llvm-svn: 375143
1 parent 990c433 commit 4ff1e34

File tree

1 file changed

+28
-19
lines changed

1 file changed

+28
-19
lines changed

llvm/utils/lit/lit/run.py

+28-19
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ class NopSemaphore(object):
1111
def acquire(self): pass
1212
def release(self): pass
1313

14-
def create_run(tests, lit_config, workers, progress_callback, timeout=None):
15-
# TODO(yln) assert workers > 0
14+
def create_run(tests, lit_config, workers, progress_callback, max_time):
1615
if workers == 1:
17-
return SerialRun(tests, lit_config, progress_callback, timeout)
18-
return ParallelRun(tests, lit_config, progress_callback, timeout, workers)
16+
return SerialRun(tests, lit_config, progress_callback, max_time)
17+
return ParallelRun(tests, lit_config, progress_callback, max_time, workers)
1918

2019
class Run(object):
2120
"""A concrete, configured testing run."""
2221

23-
def __init__(self, tests, lit_config, progress_callback, timeout):
22+
def __init__(self, tests, lit_config, progress_callback, max_time):
2423
self.tests = tests
2524
self.lit_config = lit_config
2625
self.progress_callback = progress_callback
27-
self.timeout = timeout
26+
self.max_time = max_time
2827

2928
def execute(self):
3029
"""
@@ -35,7 +34,7 @@ def execute(self):
3534
3635
The progress_callback will be invoked for each completed test.
3736
38-
If timeout is non-None, it should be a time in seconds after which to
37+
If max_time is non-None, it should be a time in seconds after which to
3938
stop executing tests.
4039
4140
Returns the elapsed testing time.
@@ -51,8 +50,7 @@ def execute(self):
5150
self.hit_max_failures = False
5251

5352
start = time.time()
54-
deadline = (start + self.timeout) if self.timeout else float('inf')
55-
self._execute(deadline)
53+
self._execute()
5654
end = time.time()
5755

5856
# Mark any tests that weren't run as UNRESOLVED.
@@ -92,23 +90,29 @@ def _consume_test_result(self, pool_result):
9290
self.hit_max_failures = True
9391

9492
class SerialRun(Run):
95-
def __init__(self, tests, lit_config, progress_callback, timeout):
96-
super(SerialRun, self).__init__(tests, lit_config, progress_callback, timeout)
93+
def __init__(self, tests, lit_config, progress_callback, max_time):
94+
super(SerialRun, self).__init__(tests, lit_config, progress_callback, max_time)
9795

98-
def _execute(self, deadline):
99-
# TODO(yln): ignores deadline
96+
def _execute(self):
97+
# TODO(yln): ignores max_time
10098
for test_index, test in enumerate(self.tests):
10199
lit.worker._execute_test(test, self.lit_config)
102100
self._consume_test_result((test_index, test))
103101
if self.hit_max_failures:
104102
break
105103

106104
class ParallelRun(Run):
107-
def __init__(self, tests, lit_config, progress_callback, timeout, workers):
108-
super(ParallelRun, self).__init__(tests, lit_config, progress_callback, timeout)
105+
def __init__(self, tests, lit_config, progress_callback, max_time, workers):
106+
super(ParallelRun, self).__init__(tests, lit_config, progress_callback, max_time)
109107
self.workers = workers
110108

111-
def _execute(self, deadline):
109+
def _execute(self):
110+
# We need to issue many wait calls, so compute the final deadline and
111+
# subtract time.time() from that as we go along.
112+
deadline = None
113+
if self.max_time:
114+
deadline = time.time() + self.max_time
115+
112116
semaphores = {
113117
k: NopSemaphore() if v is None else
114118
multiprocessing.BoundedSemaphore(v) for k, v in
@@ -142,10 +146,15 @@ def console_ctrl_handler(type):
142146
# Wait for all results to come in. The callback that runs in the
143147
# parent process will update the display.
144148
for a in async_results:
145-
timeout = deadline - time.time()
146-
a.wait(timeout)
149+
if deadline:
150+
a.wait(deadline - time.time())
151+
else:
152+
# Python condition variables cannot be interrupted unless
153+
# they have a timeout. This can make lit unresponsive to
154+
# KeyboardInterrupt, so do a busy wait with a timeout.
155+
while not a.ready():
156+
a.wait(1)
147157
if not a.successful():
148-
# TODO(yln): this also raises on a --max-time time
149158
a.get() # Exceptions raised here come from the worker.
150159
if self.hit_max_failures:
151160
break

0 commit comments

Comments
 (0)