Skip to content

Commit

Permalink
Do not instantiate ClientSession already on import (FlexMeasures#87)
Browse files Browse the repository at this point in the history
* Do not instantiate ClientSession already on import, outside of doing actual requests

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

* create session after client initialization

Signed-off-by: Nicolas Höning <nicolas@seita.nl>

---------

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
  • Loading branch information
nhoening authored Oct 1, 2024
1 parent c9f009c commit 2d12d4b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/flexmeasures_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ class FlexMeasuresClient:
polling_timeout: float = POLLING_TIMEOUT # seconds
request_timeout: float = REQUEST_TIMEOUT # seconds
polling_interval: float = POLLING_INTERVAL # seconds
session: ClientSession = ClientSession()
session: ClientSession | None = None

def __post_init__(self):
if self.session is None:
self.session = ClientSession()
if not re.match(r".+\@.+\..+", self.email):
raise EmailValidationError(
f"{self.email} is not an email address format string"
Expand Down

0 comments on commit 2d12d4b

Please sign in to comment.