-
Notifications
You must be signed in to change notification settings - Fork 8
Support for a client factory #14
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
base: main
Are you sure you want to change the base?
Conversation
|
@richo since |
|
found it: TokenFetcher._login calls httpx.AsyncClient directly at line 342. |
|
Great catch thankyou! After rolling this out creating the hass AsyncClient directly (So I can enable http2) I got some suspicious http2 shaped errors in other modules which doesn't make a ton of sense to me, but I'm gunna look further into it today. In the worst case I did just realise that franklinwh could try importing hass, and if it succeeds then use their client. Your patch isn't bad at all and I'm not ruling it out, it's just a bit frustrating to add so much API surface for such a specific and limited usecase. |
|
Ok good news and bad news! That was the problem: switching that class up a little to always use the factory now makes it load cleanly. Buuuuut, turning on http2 here is causing other clients to have it enabled, for reasons I don't fully understand :( |
I get these in my logs, commenting out http2=True in both client creations makes it go away. |
|
I asked for help in the discord, hoping someone just knows why it's doing that off the top of their head so I don't have to figure out how to attach a debugger to homeassistant. |
|
Oh my god, so I looked into the It looks like we could theoretically deep copy the client and then reinitialize its transport but doing so would make us dependant on a private api. |
|
I opened home-assistant/core#160074 |
|
@richo the big advantage of #13 is knowing the context in the caller instead of being ground down in the grimy morass that is python asyncio through callbacks. like #14, #13 also inflicts no change on the caller UNLESS they require it. the burden of richo/homeassistant-franklinwh#54 with #13 is simpler than will be required by #14, assuming the bridge can even be solved. |
Alternative implementation to #13 , would allow for a slightly nicer fix for richo/homeassistant-franklinwh#53
essentially, the idea is that consumers who don't understand or care that this exists do nothing, if you do care you just have to do something like:
and then everything after that works as though by magic.
The one thing I want to chase up is whether this erases the http2 support that someone added a while back.