Skip to content

Commit 091cbe8

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

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-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: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,37 @@ 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
)
58+
]
59+
60+
other_dispatches_running = any(
61+
running_dispatch.started_at(now)
62+
for running_dispatch in running_dispatch_list
5863
)
5964

6065
_logger.debug(
61-
"stop event %s because other_dispatches_running=%s",
66+
"%s stop event %s because other_dispatches_running=%s",
67+
"Ignoring" if other_dispatches_running else "Allowing",
6268
dispatch.id,
6369
other_dispatches_running,
6470
)
71+
72+
if other_dispatches_running:
73+
if _logger.isEnabledFor(logging.DEBUG):
74+
_logger.debug(
75+
"Active other dispatches: %s",
76+
list(
77+
running_dispatch.id
78+
for running_dispatch in running_dispatch_list
79+
),
80+
)
81+
6582
return not other_dispatches_running
6683

6784

0 commit comments

Comments
 (0)