From fc68b784c7c41c820dcffb59778db7511fe29047 Mon Sep 17 00:00:00 2001 From: Jason Gunthorpe Date: Fri, 7 Aug 2020 10:42:02 -0300 Subject: O365: Protect the page fetches in get_json_paged() with _retry_protect Getting a 404 or other error here would explode the whole thing. Instead the fetch of the next URL should be re-issued. Signed-off-by: Jason Gunthorpe --- cloud_mdir_sync/office365.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cloud_mdir_sync/office365.py b/cloud_mdir_sync/office365.py index 32ae45a..fa130a8 100644 --- a/cloud_mdir_sync/office365.py +++ b/cloud_mdir_sync/office365.py @@ -378,6 +378,11 @@ class GraphAPI(oauth.Account): async for _ in op.content.iter_any(): pass + @_retry_protect + async def __get_json_paged_next(self, uri): + async with self.session.get(uri, headers=self.headers) as op: + return await self._check_json(op) + async def get_json_paged(self, ver, path, params=None): """Return an iterator that iterates over every JSON element in a paged result""" @@ -389,8 +394,7 @@ class GraphAPI(oauth.Account): uri = resp.get("@odata.nextLink") if uri is None: break - async with self.session.get(uri, headers=self.headers) as op: - resp = await self._check_json(op) + resp = await self.__get_json_paged_next(uri) async def _execute_batch(self, batch): resp = await self.post_json("v1.0", "/$batch", batch) -- cgit v1.2.3