Skip to content

Commit 861b9ca

Browse files
committed
Added support for timeouts in messaging module
1 parent bf783c3 commit 861b9ca

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

firebase_admin/messaging.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ def __init__(self, app):
748748
'GCLOUD_PROJECT environment variable.')
749749
self._fcm_url = _MessagingService.FCM_URL.format(project_id)
750750
self._client = _http_client.JsonHttpClient(credential=app.credential.get_credential())
751+
self._timeout = app.options.get('httpTimeout')
751752

752753
@classmethod
753754
def encode_message(cls, message):
@@ -757,10 +758,11 @@ def encode_message(cls, message):
757758

758759
def send(self, message, dry_run=False):
759760
data = {'message': _MessagingService.encode_message(message)}
761+
import ipdb; ipdb.set_trace()
760762
if dry_run:
761763
data['validate_only'] = True
762764
try:
763-
resp = self._client.body('post', url=self._fcm_url, json=data)
765+
resp = self._client.body('post', url=self._fcm_url, json=data, timeout=self._timeout)
764766
except requests.exceptions.RequestException as error:
765767
if error.response is not None:
766768
self._handle_fcm_error(error)
@@ -791,7 +793,12 @@ def make_topic_management_request(self, tokens, topic, operation):
791793
url = '{0}/{1}'.format(_MessagingService.IID_URL, operation)
792794
try:
793795
resp = self._client.body(
794-
'post', url=url, json=data, headers=_MessagingService.IID_HEADERS)
796+
'post',
797+
url=url,
798+
json=data,
799+
headers=_MessagingService.IID_HEADERS,
800+
timeout=self._timeout
801+
)
795802
except requests.exceptions.RequestException as error:
796803
if error.response is not None:
797804
self._handle_iid_error(error)

0 commit comments

Comments
 (0)