Fix flaky multiprocessing tests (#7413)

This commit is contained in:
Edward Oakes
2020-03-03 15:07:59 -06:00
committed by GitHub
parent fb76092d75
commit b0bf5450c2
2 changed files with 20 additions and 4 deletions
+5 -4
View File
@@ -31,7 +31,7 @@ class ResultThread(threading.Thread):
callback=None,
error_callback=None,
total_object_ids=None):
threading.Thread.__init__(self)
threading.Thread.__init__(self, daemon=True)
self._got_error = False
self._object_ids = []
self._num_ready = 0
@@ -232,13 +232,14 @@ class OrderedIMapIterator(IMapIterator):
if self._next_chunk_index == self._total_chunks:
raise StopIteration
while timeout is None or timeout > 0:
# This loop will break when the next index in order is ready or
# self._result_thread.next_ready_index() raises a timeout.
index = -1
while index != self._next_chunk_index:
start = time.time()
index = self._result_thread.next_ready_index(timeout=timeout)
self._submit_next_chunk()
self._submitted_chunks[index] = True
if index == self._next_chunk_index:
break
if timeout is not None:
timeout = max(0, timeout - (time.time() - start))