Skip to content

Commit

Permalink
CV2-5589 add explicit timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Nov 13, 2024
1 parent 0362187 commit e78943c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/queue/processor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List
import json

from datetime import datetime
import requests

from lib import schemas
Expand Down Expand Up @@ -60,15 +60,17 @@ def send_callback(self, message):
try:
schemas.parse_output_message(message) # will raise exceptions if not valid, e.g. too large of a message
callback_url = message.get("body", {}).get("callback_url")
start_time = datetime.now()
response = requests.post(
callback_url,
timeout=30,
json=message,
# headers={"Content-Type": "application/json"},
)
# check for error with the callback
if response.ok != True:
logger.error(f"Callback error responding to {callback_url} :{response}")
except Exception as e:
duration = (datetime.now() - start_time).total_seconds()
logger.error(
f"Callback fail! Failed with {e} on {callback_url} with message of {message}"
f"Callback fail! Failed with {e} on {callback_url} with message of {message}, duration was {duration}"
)

0 comments on commit e78943c

Please sign in to comment.