Skip to content

Add http timeout to sseclient #291

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions firebase_admin/_sseclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@
class KeepAuthSession(transport.requests.AuthorizedSession):
"""A session that does not drop authentication on redirects between domains."""

def __init__(self, credential):
def __init__(self, credential, http_timeout):
super(KeepAuthSession, self).__init__(credential)
self.http_timeout = http_timeout

def rebuild_auth(self, prepared_request, response):
pass
Expand Down Expand Up @@ -107,7 +108,7 @@ def _connect(self):
if self.should_connect:
if self.last_id:
self.requests_kwargs['headers']['Last-Event-ID'] = self.last_id
self.resp = self.session.get(self.url, stream=True, **self.requests_kwargs)
self.resp = self.session.get(self.url, stream=True, timeout=self.session.http_timeout, **self.requests_kwargs)
self.resp_iterator = self.resp.iter_content(decode_unicode=True)
self.resp.raise_for_status()
else:
Expand Down
2 changes: 1 addition & 1 deletion firebase_admin/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def listen(self, callback):
Raises:
ApiCallError: If an error occurs while starting the initial HTTP connection.
"""
session = _sseclient.KeepAuthSession(self._client.credential)
session = _sseclient.KeepAuthSession(self._client.credential, self._client.timeout)
return self._listen_with_session(callback, session)

def transaction(self, transaction_update):
Expand Down