Skip to content

Commit aeafbee

Browse files
committed
Make minor changes related to asyncio
1 parent edcaadd commit aeafbee

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

app/load_tables.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from asyncio import gather, to_thread
1+
from asyncio import gather
22
from collections.abc import Iterable, Mapping
33
from logging import getLogger
44
from pathlib import Path
@@ -144,13 +144,11 @@ async def load_tables(
144144
session.tables.data_transaction(),
145145
):
146146
await gather(
147-
to_thread(
148-
session.tables[Skeleton.tables.STATION_INFORMATION.name].load,
149-
station_information_df,
147+
session.tables[Skeleton.tables.STATION_INFORMATION.name].load_async(
148+
station_information_df
150149
),
151-
to_thread(
152-
session.tables[Skeleton.tables.STATION_STATUS.name].load,
153-
station_status_df,
150+
session.tables[Skeleton.tables.STATION_STATUS.name].load_async(
151+
station_status_df
154152
),
155153
)
156154
_LOGGER.info("Tables loaded.")

app/util/read_json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ async def read_json(
2121
response = await http_client.get(url)
2222
response.raise_for_status()
2323
json_bytes = await response.aread()
24+
# Parse JSON in separate thread to not block the event loop.
2425
return await to_thread(json.loads, json_bytes)

0 commit comments

Comments
 (0)