mirror of
https://github.com/wassname/ray.git
synced 2026-07-04 18:32:13 +08:00
Fix flaky multiprocessing tests (#7413)
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user