-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Create new websession if more than one entry in Tesla #478 8000 86
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically I think the session should be closed if we create new one when the entry is unloaded. Same goes with the use in the config entry setup.
I'm not sure it matter much though. I think this is good enough.
Doesn't the auto close handle that? |
The auto close/cleanup parameter to async_create_clientsession will cleanup on home assistant shutdown. But it won't clean up on a config entry re/un-load. So each reload of the component will leave a lingering clientsession object. Since that object shared the connection pool, it's not going to be that bad. Just a very minor memory leak. The correct way would be to use auto_cleanup=False and explicitly call session.detach() when the entry or home assistant stops. @balloob |
That's probably better indeed. If detach ever does something more, we would end up not calling it. But that's better. |
Looking at the source, it looks like ClientSession will complain when it's not closed when it's garbage collected, but closing is a no-op when not owner of the connector. |
Do we need to have a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be one option. But those is good enough.
Breaking change
Proposed change
Detect if multiple config entries and only allowed the first config entry to use the shared ClientSession with HA. This is necessary because each account needs its own cookies.
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
This PR fixes or closes issue: fixes Adding more than one Tesla mixes up attributes #47506
This PR is related to issue: Adding more than one Tesla mixes up attributes #47506
Link to documentation pull request:
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: