Commit b732bc8b authored by Antoine Millet's avatar Antoine Millet

Added AsyncManager.iter iterator.

parent 5c471b8c
......@@ -76,7 +76,19 @@ class AsyncWatcher(object):
>>> for msg in watcher.wait(timeout=60):
>>> process(msg)
responses = []
return list(self.iter(timeout, max_wait))
def iter(self, timeout=None, max_wait=None):
Work like :meth:`AsyncWatcher.wait` but return an iterable, instead of
a list object.
.. note::
Responses are yielded by the iterable when they are received, so you
can start the processing of response before receiving all.
while self.remains:
dt, response = self._get_in_queue(timeout=timeout)
......@@ -84,12 +96,10 @@ class AsyncWatcher(object):
if timeout is not None:
timeout -= dt
yield response
# Check for max_wait:
if max_wait is not None:
max_wait -= 1
if not max_wait:
return responses
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