Skip to content

Commit

Permalink
Handle errors when tokenizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jan 16, 2022
1 parent 53c2515 commit 5e8e0c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
5 changes: 5 additions & 0 deletions app/utils/meta.py
Expand Up @@ -53,6 +53,11 @@ async def tokenize(request, url: str) -> tuple[str, bool]:
response = await session.post(
api, data={"url": default_url}, headers={"X-API-KEY": api_key}
)
if response.status >= 500:
settings.REMOTE_TRACKING_ERRORS += 1
logger.info(f"Tracker error count: {settings.REMOTE_TRACKING_ERRORS}")
return default_url, False

data = await response.json()
return data["url"], data["url"] != url

Expand Down
50 changes: 31 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -61,7 +61,7 @@ pytest-random = "*"
pytest-rerunfailures = "^9.1"
pytest-cov = "^2.7"
sanic-testing = "^0.8.2"
locust = "^1.2.3"
locust = "^2.5.1"

# Coverage
coveragespace = "^4.2"
Expand Down

0 comments on commit 5e8e0c7

Please sign in to comment.