Skip to content
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

Use aiozoneinfo to avoid blocking io inside ZoneInfo #1232

Merged
merged 3 commits into from
Nov 15, 2024

Conversation

wslaghekke
Copy link
Contributor

Proposed Changes

The current version throws a warning when used inside Home Assistant because of blocking calls to listdir, that happens inside the call to ZoneInfo, use aiozoneinfo to avoid blocking

Related Issues

home-assistant/core#123018

pyproject.toml Outdated
@@ -28,6 +28,7 @@ version = "0.0.0"
aiohttp = ">=3.0.0"
python = "^3.11"
yarl = ">=1.6.0"
aiozoneinfo = "^0.2.1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a dependency, we can also move this one out of the function scope and put it e.g., into a constant. The timezone isn't dynamic.

../Frenck

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to instantiate a ZoneInfo on construct instead, is that how you would prefer it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That still makes it a class member.

Instead, it can be just defined as a constant at the top of the file and use the constant later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oh, sorry i misunderstood, i don't write python usually, so didn't know the Usual style rules,
I've made it into a const now

@frenck frenck added the bugfix Inconsistencies or issues which will cause a problem for users or implementers. label Nov 15, 2024
@frenck frenck marked this pull request as draft November 15, 2024 09:21
@frenck frenck marked this pull request as ready for review November 15, 2024 12:51
Copy link
Owner

@frenck frenck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @wslaghekke 👍

../Frenck

@frenck frenck merged commit 8511e9d into frenck:main Nov 15, 2024
13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix Inconsistencies or issues which will cause a problem for users or implementers.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants