aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@mellanox.com>2020-06-12 11:01:02 -0300
committerJason Gunthorpe <jgg@mellanox.com>2020-06-14 22:20:54 -0300
commite241f83acb481c08881050d8b07717be7784bcc3 (patch)
tree96a7672cdc1e6acd1d76fc6eb6471cff7e14fcc1
parentb7d27e25754bb927f588e6219c31b0e59a07d1d4 (diff)
downloadcloud_mdir_sync-e241f83acb481c08881050d8b07717be7784bcc3.tar.gz
cloud_mdir_sync-e241f83acb481c08881050d8b07717be7784bcc3.tar.bz2
cloud_mdir_sync-e241f83acb481c08881050d8b07717be7784bcc3.zip
O365: Log throttling in a more informative way
For some reason the graph server has started to throttle message modification after 3-5 requests, I assume it is a server bug, so make the logging clearer for now. Also use the response headers to guide the retry timer. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--cloud_mdir_sync/office365.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/cloud_mdir_sync/office365.py b/cloud_mdir_sync/office365.py
index d68e75d..9c8ee62 100644
--- a/cloud_mdir_sync/office365.py
+++ b/cloud_mdir_sync/office365.py
@@ -37,9 +37,15 @@ def _retry_protect(func):
self.owa_token = None
await self.authenticate()
continue
+ if e.code == 429: # Too Many Requests
+ delay = int(e.headers.get("Retry-After", 10))
+ self.cfg.logger.error(
+ f"Graph returns {e} Too Many Requests, {e.headers.get('Rate-Limit-Reason')}, delaying {delay}"
+ )
+ await asyncio.sleep(delay)
+ continue
if (e.code == 503 or # Service Unavilable
e.code == 509 or # Bandwidth Limit Exceeded
- e.code == 429 or # Too Many Requests
e.code == 504 or # Gateway Timeout
e.code == 200): # Success, but error JSON
self.cfg.logger.error(f"Graph returns {e}, delaying")