Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Jul 18, 2021
1 parent 32003b6 commit 3acf153
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions resources/lib/services/nfsession/session/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import resources.lib.common as common
from resources.lib.database.db_utils import TABLE_SESSION
from resources.lib.globals import G
# from resources.lib.services.tcp_keep_alive import enable_tcp_keep_alive
from resources.lib.utils.logging import LOG

if TYPE_CHECKING: # This variable/imports are used only by the editor, so not at runtime
Expand Down Expand Up @@ -46,7 +45,6 @@ def _init_session(self):
# (http1=False, http2=True) means that the client know that server support HTTP/2 and avoid to do negotiations,
# prior knowledge: https://python-hyper.org/projects/hyper-h2/en/v2.3.1/negotiating-http2.html#prior-knowledge
self.session = httpx.Client(http1=False, http2=True)
# enable_tcp_keep_alive(self.session)
self.session.max_redirects = 10 # Too much redirects should means some problem
self.session.headers.update({
'User-Agent': common.get_user_agent(enable_android_mediaflag_fix=True),
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/services/nfsession/session/http_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def try_refresh_session_data(self, raise_exception=False):
raise NotLoggedInError from exc
except httpx.RequestError:
import traceback
LOG.warn('Failed to refresh session data, request error (RequestException)')
LOG.warn('Failed to refresh session data, request error (RequestError)')
LOG.warn(traceback.format_exc())
if raise_exception:
raise
Expand Down Expand Up @@ -207,6 +207,7 @@ def _api_url(endpoint_address):
baseurl = G.LOCAL_DB.get_value('api_endpoint_url', table=TABLE_SESSION)
return f'{baseurl}{endpoint_address}'


def _raise_api_error(decoded_response):
if decoded_response.get('status', 'success') == 'error':
raise APIError(decoded_response.get('message'))
Expand Down

0 comments on commit 3acf153

Please sign in to comment.