1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-06-04 01:21:03 +03:00

Fix up companion.Session.close() refactor

* When PyCharm made a mess I accidentally undid two renames in
  EDMarketConnector.py...
* ... but one of those actually *does* need to only close the session.  So
  made a new Session.close() that performs only the closing, with
  Session.reinit_session() now utilising that.
This commit is contained in:
Athanasius 2022-12-22 09:15:16 +00:00
parent f7e0575167
commit 292b449cf6
No known key found for this signature in database
GPG Key ID: 772697E181BB2767
2 changed files with 10 additions and 6 deletions

View File

@ -1253,7 +1253,7 @@ class AppWindow(object):
except companion.CredentialsRequireRefresh: except companion.CredentialsRequireRefresh:
# We need to 'close' the auth else it'll see STATE_OK and think login() isn't needed # We need to 'close' the auth else it'll see STATE_OK and think login() isn't needed
companion.session.close() companion.session.reinit_session()
# LANG: Frontier CAPI Access Token expired, trying to get a new one # LANG: Frontier CAPI Access Token expired, trying to get a new one
self.status['text'] = _('CAPI: Refreshing access token...') self.status['text'] = _('CAPI: Refreshing access token...')
if companion.session.login(): if companion.session.login():

View File

@ -732,6 +732,14 @@ class Session(object):
self.auth = None self.auth = None
raise # Bad thing happened raise # Bad thing happened
def close(self) -> None:
"""Close the `request.Session()."""
try:
self.requests_session.close()
except Exception as e:
logger.debug('Frontier Auth: closing', exc_info=e)
def reinit_session(self, reopen: bool = True) -> None: def reinit_session(self, reopen: bool = True) -> None:
""" """
Re-initialise the session's `request.Session()`. Re-initialise the session's `request.Session()`.
@ -739,11 +747,7 @@ class Session(object):
:param reopen: Whether to open a new session. :param reopen: Whether to open a new session.
""" """
self.state = Session.STATE_INIT self.state = Session.STATE_INIT
try: self.close()
self.requests_session.close()
except Exception as e:
logger.debug('Frontier Auth: closing', exc_info=e)
if reopen: if reopen:
self.requests_session = requests.Session() self.requests_session = requests.Session()