Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue a purge request when we get a stale serial. #57

Merged
merged 4 commits into from
Oct 18, 2018
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
16 changes: 15 additions & 1 deletion src/bandersnatch/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,22 @@ def get(self, path, required_serial, **kw):
required_serial, path, got_serial
)
)
# HACK: The following attempts to purge the cache of the page we
# just tried to fetch. This works around PyPI's caches sometimes
# returning a stale serial for a package. Ideally, this should
# be fixed on the PyPI side, at which point the following code
# should be removed.
logger.debug(f"Issuing a PURGE for {path} to clear the cache")
try:
self.session.request("PURGE", path, timeout=self.timeout)
except requests.exceptions.HTTPError:
logger.warning(
"Got an error when attempting to clear the cache", exc_info=True
)

raise StalePage(
"Expected PyPI serial {} for request {} but got {}".format(
"Expected PyPI serial {} for request {} but got {}. "
+ "HTTP PURGE has been issued to the request url".format(
required_serial, path, got_serial
)
)
Expand Down