Skip to content

Commit 5a3577d

Browse files
committed
fix(impl): Return to the async client
1 parent 32ddad8 commit 5a3577d

File tree

13 files changed

+294
-275
lines changed

13 files changed

+294
-275
lines changed

src/quartz_api/cmd/main.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,22 @@ async def _lifespan(server: FastAPI, conf: ConfigTree) -> AsyncGenerator[None]:
9595
case "dataplatform":
9696
from ocf.dp.dp_data import service_pb2_grpc
9797
trace_interceptor = trace.TraceInterceptor()
98-
grpc_channel = grpc.insecure_channel(
98+
grpc_channel = grpc.aio.insecure_channel(
9999
target=conf.get_string("backend.dataplatform.host") \
100100
+ ":" + conf.get_string("backend.dataplatform.port"),
101+
interceptors=[trace_interceptor],
101102
)
102-
intercept_channel = grpc.intercept_channel(
103-
grpc_channel,
104-
trace_interceptor,
105-
)
106-
client = service_pb2_grpc.DataPlatformDataServiceStub(intercept_channel)
103+
client = service_pb2_grpc.DataPlatformDataServiceStub(grpc_channel)
107104
storage = DataPlatformStorage.from_dp(dp_client=client)
108105

109106
if "uk_national" in conf.get_string("api.routers").split(","):
110107
# Populate the GSP ID to UUID mapping
111-
resp = storage.get_locations(
108+
resp = await storage.get_locations(
112109
location_type=models.LocationType.GSP,
113110
energy_type=models.EnergyType.SOLAR,
114111
authdata={},
115112
)
116-
resp += storage.get_locations(
113+
resp += await storage.get_locations(
117114
location_type=models.LocationType.NATION,
118115
energy_type=models.EnergyType.SOLAR,
119116
authdata={},
@@ -139,7 +136,7 @@ async def _lifespan(server: FastAPI, conf: ConfigTree) -> AsyncGenerator[None]:
139136

140137
gsp_id_map.clear()
141138
if grpc_channel:
142-
grpc_channel.close()
139+
await grpc_channel.close()
143140

144141

145142
def _create_server(conf: ConfigTree) -> FastAPI:

0 commit comments

Comments
 (0)