zytedata/python-zyte-api

Add URL to Logs when Retrying

BurnzZ opened this issue · 0 comments

BurnzZ commented

Currently, this section of the code https://github.com/zytedata/python-zyte-api/blob/main/zyte_api/aio/client.py#L62-L130 produces this DEBUG log when retrying errors:

[zyte_api.aio.retry] Retrying zyte_api.aio.client.AsyncClient.request_raw.<locals>.request in 7.430951650096189 seconds as it raised RequestError: RequestError: 520, message=, headers=<CIMultiDictProxy('Date': 'Tue, 19 Dec 2023 09:07:00 GMT', 'Content-Type': 'application/problem+json', 'Content-Length': '301', 'Connection': 'keep-alive', 'Retry-After': '60', 'Request-Id': '8dc64f033de37f442807c9d378c5044b', 'Vary': 'Accept-Encoding', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Access-Control-Allow-Credentials': 'true', 'Access-Control-Expose-Headers': '*, X-Project-Key', 'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE, PATCH, OPTIONS', 'Access-Control-Allow-Headers': 'DNT, Keep-Alive, User-Agent, X-Requested-With, If-Modified-Since, Cache-Control, Content-Type, Range, Authorization, X-Project-Key', 'Access-Control-Max-Age': '1728000')>, body=b'{"type":"/download/temporary-error","title":"Temporary Downloading Error","status":520,"detail":"There is a downloading problem which might be temporary. Retry in N seconds from \'Retry-After\' header or open a support ticket from https://support.zyte.com/support/tickets/new if it fails consistently."}', request_id=8dc64f033de37f442807c9d378c5044b.

Notice that the URL of the request in isn't logged here, but the header is.