Skip to content

Commit 9fb20da

Browse files
committed
Adjust logging to be more informative and clear
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent 227da85 commit 9fb20da

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/frequenz/dispatch/_actor_dispatcher.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,13 @@ async def _stop_actor(self, stopping_dispatch: Dispatch, msg: str) -> None:
253253
identity = self._dispatch_identity(stopping_dispatch)
254254

255255
if actor_and_channel := self._actors.pop(identity, None):
256+
_logger.info("Stopping actor for dispatch type %r", stopping_dispatch.type)
256257
await actor_and_channel.actor.stop(msg)
257258
await actor_and_channel.channel.close()
258259
else:
259260
_logger.warning(
260-
"Actor for dispatch type %r is not running", stopping_dispatch.type
261+
"Actor for dispatch type %r is not running, ignoring stop request",
262+
stopping_dispatch.type,
261263
)
262264

263265
async def _run(self) -> None:

src/frequenz/dispatch/_merge_strategies.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,32 @@ def filter(
4848
_logger.debug("Keeping start event %s", dispatch.id)
4949
return True
5050

51-
other_dispatches_running = any(
52-
existing_dispatch.started_at(now)
51+
running_dispatch_list = (
52+
existing_dispatch
5353
for existing_dispatch in dispatches.values()
5454
if (
5555
self.identity(existing_dispatch) == self.identity(dispatch)
5656
and existing_dispatch.id != dispatch.id
5757
)
5858
)
5959

60+
other_dispatches_running = any(
61+
dispatch.started_at(now) for dispatch in running_dispatch_list
62+
)
63+
6064
_logger.debug(
61-
"stop event %s because other_dispatches_running=%s",
65+
"%s stop event %s because other_dispatches_running=%s",
66+
"Ignoring" if other_dispatches_running else "Allowing",
6267
dispatch.id,
6368
other_dispatches_running,
6469
)
70+
71+
if other_dispatches_running:
72+
_logger.debug(
73+
"Active other dispatches: %s",
74+
list(dispatch.id for dispatch in running_dispatch_list),
75+
)
76+
6577
return not other_dispatches_running
6678

6779

0 commit comments

Comments
 (0)