MCPcopy Create free account
hub / github.com/apache/devlake / pause_if_too_many_requests

Method pause_if_too_many_requests

backend/python/pydevlake/pydevlake/api.py:325–337  ·  view source on GitHub ↗

Pause execution if a response has a 429 status TOO_MANY_REQUEST. for the number of seconds indicated in the 'Retry-After' header, or 60 seconds if this header is missing. Retry the failed request afterwards.

(self, response: Response)

Source from the content-addressed store, hash-verified

323
324 @response_hook
325 def pause_if_too_many_requests(self, response: Response):
326 """
327 Pause execution if a response has a 429 status TOO_MANY_REQUEST.
328 for the number of seconds indicated in the 'Retry-After' header,
329 or 60 seconds if this header is missing.
330 Retry the failed request afterwards.
331 """
332 if response.status == HTTPStatus.TOO_MANY_REQUESTS:
333 retry_after = response.headers.get('Retry-After', 60)
334 logger.warning(f'Got TOO_MANY_REQUESTS response, sleep {int(retry_after)} seconds')
335 time.sleep(retry_after)
336 return self.send(response.request)
337 return response
338
339 @response_hook
340 def handle_error(self, response):

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
sendMethod · 0.80

Tested by

no test coverage detected