Skip to content

Commit

Permalink
fix: catch exceptions when echoing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Avram Tudor committed Oct 15, 2024
1 parent a1a074b commit f050234
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions skynet/modules/ttt/summaries/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import random

from fastapi import Request
from fastapi_versionizer.versionizer import Versionizer

Expand Down Expand Up @@ -28,11 +29,14 @@ async def echo_requests(request: Request, call_next):
counter = random.randrange(1, 101)

if counter <= echo_requests_percent:
await http_client.post(
f'{echo_requests_base_url}/{request.url.path}',
headers={'Authorization': f'Bearer {echo_requests_token}'},
json=await request.json(),
)
try:
await http_client.post(
f'{echo_requests_base_url}{request.url.path}',
headers={'Authorization': f'Bearer {echo_requests_token}'},
json=await request.json(),
)
except Exception as e:
log.warning(f'Failed to echo request: {e}')

return await call_next(request)

Expand Down

0 comments on commit f050234

Please sign in to comment.