Skip to content

Commit

Permalink
pypi, retry when receiving a 200 with empty body
Browse files Browse the repository at this point in the history
For some reason, pypi is returning a 200 and an empty body from
time to time. The next time you query the same endpoint it
returns a proper JSON object. This is not fixing a bug in
poetry, but working around the issue.
  • Loading branch information
j-martin committed Nov 5, 2021
1 parent 5dcf24d commit 8ea86ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions poetry/repositories/pypi_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ def _get_release_info(self, name: str, version: str) -> dict:
def _get(self, endpoint: str) -> Union[dict, None]:
try:
json_response = self.session.get(self._base_url + endpoint)
if json_response.status_code == 200 and json_response.content == b"":
logger.warn("Got empty response from PyPI for %s. Retrying...", endpoint)
json_response = self.session.get(self._base_url + endpoint)
except requests.exceptions.TooManyRedirects:
# Cache control redirect loop.
# We try to remove the cache and try again
Expand Down

0 comments on commit 8ea86ad

Please sign in to comment.