Skip to content

Commit 2337228

Browse files
committed
Remove the initial wait time in the power distributor
The power distributor is no longer controlled directly by the users, but instead gets requests only from the power manager. So if will not receive requests until there's data. But if it receives requests when there's no data, it will return an `Error` response, saying there's no data. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b45a810 commit 2337228

File tree

3 files changed

+0
-14
lines changed

3 files changed

+0
-14
lines changed

benchmarks/power_distribution/power_distributor.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ async def run_test( # pylint: disable=too-many-locals
120120
requests_receiver=power_request_channel.new_receiver(),
121121
results_sender=power_result_channel.new_sender(),
122122
component_pool_status_sender=battery_status_channel.new_sender(),
123-
wait_for_data_sec=2.0,
124123
):
125124
tasks: list[Coroutine[Any, Any, list[Result]]] = []
126125
tasks.append(send_requests(batteries, num_requests))

src/frequenz/sdk/actor/power_distributing/power_distributing.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
"""
1313

1414

15-
import asyncio
16-
1715
from frequenz.channels import Receiver, Sender
1816
from frequenz.client.microgrid import ComponentCategory, ComponentType, InverterType
1917

@@ -60,7 +58,6 @@ def __init__( # pylint: disable=too-many-arguments
6058
requests_receiver: Receiver[Request],
6159
results_sender: Sender[Result],
6260
component_pool_status_sender: Sender[ComponentPoolStatus],
63-
wait_for_data_sec: float,
6461
*,
6562
component_category: ComponentCategory,
6663
component_type: ComponentType | None = None,
@@ -74,8 +71,6 @@ def __init__( # pylint: disable=too-many-arguments
7471
results_sender: Sender for sending results to the power manager.
7572
component_pool_status_sender: Channel for sending information about which
7673
components are expected to be working.
77-
wait_for_data_sec: How long actor should wait before processing first
78-
request. It is a time needed to collect first components data.
7974
component_category: The category of the components that this actor is
8075
responsible for.
8176
component_type: The type of the component of the given category that this
@@ -96,7 +91,6 @@ def __init__( # pylint: disable=too-many-arguments
9691
self._component_type = component_type
9792
self._requests_receiver = requests_receiver
9893
self._result_sender = results_sender
99-
self._wait_for_data_sec = wait_for_data_sec
10094

10195
self._component_manager: ComponentManager
10296
if component_category == ComponentCategory.BATTERY:
@@ -130,9 +124,6 @@ async def _run(self) -> None: # pylint: disable=too-many-locals
130124
"""
131125
await self._component_manager.start()
132126

133-
# Wait few seconds to get data from the channels created above.
134-
await asyncio.sleep(self._wait_for_data_sec)
135-
136127
async for request in self._requests_receiver:
137128
await self._component_manager.distribute_power(request)
138129

src/frequenz/sdk/microgrid/_power_wrapper.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
_logger = logging.getLogger(__name__)
3232

33-
_POWER_DISTRIBUTING_ACTOR_WAIT_FOR_DATA_SEC = 2.0
34-
3533

3634
class PowerWrapper:
3735
"""Wrapper around the power managing and power distributing actors."""
@@ -80,7 +78,6 @@ def __init__(
8078

8179
self._power_distributing_actor: PowerDistributingActor | None = None
8280
self._power_managing_actor: _power_managing.PowerManagingActor | None = None
83-
self._pd_wait_for_data_sec: float = _POWER_DISTRIBUTING_ACTOR_WAIT_FOR_DATA_SEC
8481

8582
def _start_power_managing_actor(self) -> None:
8683
"""Start the power managing actor if it is not already running."""
@@ -151,7 +148,6 @@ def _start_power_distributing_actor(self) -> None:
151148
requests_receiver=self._power_distribution_requests_channel.new_receiver(),
152149
results_sender=self._power_distribution_results_channel.new_sender(),
153150
component_pool_status_sender=self.status_channel.new_sender(),
154-
wait_for_data_sec=self._pd_wait_for_data_sec,
155151
)
156152
self._power_distributing_actor.start()
157153

0 commit comments

Comments
 (0)