1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-14 08:17:13 +03:00

companion: Have Session.close() actually open a new one by default

Both current callers to this are in code paths where it is expected that
Session.requests_session will be valid later.  Rather than assign a new
session at the call sites just make this by default open a new session.
This commit is contained in:
Athanasius 2022-12-21 13:27:53 +00:00
parent 2b79b89803
commit e65a1e6afa
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -733,7 +733,7 @@ class Session(object):
self.auth = None
raise # Bad thing happened
def close(self) -> None:
def close(self, reopen: bool = True) -> None:
"""Close Frontier authorization session."""
self.state = Session.STATE_INIT
if self.requests_session:
@ -742,8 +742,11 @@ class Session(object):
except Exception as e:
logger.debug('Frontier Auth: closing', exc_info=e)
self.requests_session = None
self.requests_session = None
# 2022-12-21: Current callers all need a *new* session.
if reopen:
self.requests_session = requests.Session()
def invalidate(self) -> None:
"""Invalidate Frontier authorization credentials."""