mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
WIP - adding request timeout
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import json
|
||||
from monotonic import monotonic
|
||||
from requests import (request, RequestException)
|
||||
|
||||
from requests.exceptions import HTTPError
|
||||
from app.clients import (STATISTICS_DELIVERED, STATISTICS_FAILURE)
|
||||
from app.clients.sms import (SmsClient, SmsClientResponseException)
|
||||
|
||||
@@ -104,7 +104,8 @@ class MMGClient(SmsClient):
|
||||
headers={
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Basic {}'.format(self.api_key)
|
||||
}
|
||||
},
|
||||
timeout=60
|
||||
)
|
||||
|
||||
response.raise_for_status()
|
||||
@@ -117,6 +118,9 @@ class MMGClient(SmsClient):
|
||||
except RequestException as e:
|
||||
self.record_outcome(False, e.response)
|
||||
raise MMGClientResponseException(response=e.response, exception=e)
|
||||
except HTTPError as e:
|
||||
self.record_outcome(False, e.response)
|
||||
raise MMGClientResponseException(response=e.response, exception=e)
|
||||
finally:
|
||||
elapsed_time = monotonic() - start_time
|
||||
self.statsd_client.timing("clients.mmg.request-time", elapsed_time)
|
||||
|
||||
Reference in New Issue
Block a user