Skip to content

Commit d268ec7

Browse files
committed
Properly await for AddInclusionBounds
Without this, the function call will never actually run. I'm not sure if this was working anyways because of some obscure implementation detail in grpcio, but in normal python a not awaited async function should never actually run. Besides this, for sure errors can't be really caught without the await either. This was detected while migrating to betterproto, as betterproto has correct type hints. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 98dcf55 commit d268ec7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/frequenz/client/microgrid/_client.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from frequenz.channels import Receiver
3333
from frequenz.client.base import retry, streaming
3434
from google.protobuf.empty_pb2 import Empty # pylint: disable=no-name-in-module
35+
from google.protobuf.timestamp_pb2 import Timestamp # pylint: disable=no-name-in-module
3536

3637
from ._component import (
3738
Component,
@@ -469,11 +470,14 @@ async def set_bounds(
469470

470471
target_metric = PbSetBoundsParam.TargetMetric.TARGET_METRIC_POWER_ACTIVE
471472
try:
472-
self.api.AddInclusionBounds(
473-
PbSetBoundsParam(
474-
component_id=component_id,
475-
target_metric=target_metric,
476-
bounds=PbBounds(lower=lower, upper=upper),
473+
await cast(
474+
Awaitable[Timestamp],
475+
self.api.AddInclusionBounds(
476+
PbSetBoundsParam(
477+
component_id=component_id,
478+
target_metric=target_metric,
479+
bounds=PbBounds(lower=lower, upper=upper),
480+
),
477481
),
478482
)
479483
except grpc.aio.AioRpcError as err:

0 commit comments

Comments
 (0)