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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/twentemilieu/twentemilieu.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
TwenteMilieuError,
)

TIMEZONE_INFO = ZoneInfo("Europe/Amsterdam")


class WasteType(IntEnum):
"""Enum for the types of waste."""
Expand Down Expand Up @@ -169,16 +171,15 @@ async def update(self) -> dict[WasteType, list[date]]:
"""
await self.unique_id()

timezone = ZoneInfo("Europe/Amsterdam")
response = await self._request(
"GetCalendar",
data={
"companyCode": self.company_code,
"uniqueAddressID": self._unique_id,
"startDate": (datetime.now(tz=timezone) - timedelta(days=1))
"startDate": (datetime.now(tz=TIMEZONE_INFO) - timedelta(days=1))
.date()
.isoformat(),
"endDate": (datetime.now(tz=timezone) + timedelta(days=365))
"endDate": (datetime.now(tz=TIMEZONE_INFO) + timedelta(days=365))
.date()
.isoformat(),
},
Expand All @@ -197,7 +198,7 @@ async def update(self) -> dict[WasteType, list[date]]:
pickup_date_raw,
"%Y-%m-%dT%H:%M:%S",
)
.replace(tzinfo=timezone)
.replace(tzinfo=TIMEZONE_INFO)
.date()
)
pickups[waste_type].append(pickup_date)
Expand Down