From ad69c42d889f306ac7bf68f3bcb91fbbb5cdb5f8 2013-05-11 21:16:11 From: Anton Akhmerov Date: 2013-05-11 21:16:11 Subject: [PATCH] speed up AsyncResult._wait_for_outputs (don't waste 0.01 seconds) Greatly reduces waiting time on ready() call for large calculations. --- diff --git a/IPython/parallel/client/asyncresult.py b/IPython/parallel/client/asyncresult.py index 5ddf697..52b3d72 100644 --- a/IPython/parallel/client/asyncresult.py +++ b/IPython/parallel/client/asyncresult.py @@ -452,14 +452,14 @@ class AsyncResult(object): timeout = -1 tic = time.time() - self._client._flush_iopub(self._client._iopub_socket) - self._outputs_ready = all(md['outputs_ready'] for md in self._metadata) - while not self._outputs_ready: - time.sleep(0.01) + while True: self._client._flush_iopub(self._client._iopub_socket) - self._outputs_ready = all(md['outputs_ready'] for md in self._metadata) - if timeout >= 0 and time.time() > tic + timeout: + self._outputs_ready = all(md['outputs_ready'] + for md in self._metadata) + if self._outputs_ready or \ + (timeout >= 0 and time.time() > tic + timeout): break + time.sleep(0.01) @check_ready def display_outputs(self, groupby="type"):