Skip to content

Commit

Permalink
Fix #126 (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel authored Oct 15, 2018
1 parent e5af083 commit e3ba039
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions msrest/async_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def __init__(self, *args, **kwargs):
"""
self._async_get_next = kwargs.get("async_command")
if not self._async_get_next:
_LOGGER.warning("Paging async iterator protocol is not available for %s",
self.__class__.__name__)
_LOGGER.debug("Paging async iterator protocol is not available for %s",
self.__class__.__name__)

async def async_get(self, url):
"""Get an arbitrary page.
Expand All @@ -53,13 +53,18 @@ async def async_get(self, url):
return await self.async_advance_page()

async def async_advance_page(self):
if not self._async_get_next:
raise NotImplementedError(
"The class %s does not support async paging at the moment.",
self.__class__.__name__
)
if self.next_link is None:
raise StopAsyncIteration("End of paging")
self._current_page_iter_index = 0
self._response = await self._async_get_next(self.next_link)
self._derserializer(self, self._response)
return self.current_page

async def __anext__(self):
"""Iterate through responses."""
# Storing the list iterator might work out better, but there's no
Expand Down

0 comments on commit e3ba039

Please sign in to comment.