Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/ghstack/github_real.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,11 @@ async def arest(self, method: str, path: str, **kwargs: Any) -> Any:

async with getattr(session, method)(url, **request_kwargs) as resp:
logging.debug("%s response status: %s", log_prefix, resp.status)
resp_text = await resp.text()
try:
r = await resp.json()
except (aiohttp.ContentTypeError, ValueError):
logging.debug(
"%s response body:\n%s", log_prefix, await resp.text()
)
r = json.loads(resp_text)
except ValueError:
logging.debug("%s response body:\n%s", log_prefix, resp_text)
raise
else:
pretty_json = json.dumps(r, indent=1)
Expand All @@ -251,7 +250,7 @@ async def arest(self, method: str, path: str, **kwargs: Any) -> Any:
# GitHub doesn't document the content of these messages, but this
# seems to be an accurate way to find secondary rate limits. Any
# other reason for 403 or 429 will fall through to the error below.
elif b"rate limit" in resp.content.lower():
elif "rate limit" in resp_text.lower():
retry_after_seconds = resp.headers.get("retry-after")
if retry_after_seconds:
sleep_time = int(retry_after_seconds)
Expand Down
Loading