File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change 1515## Bug Fixes
1616
1717* The merge by type class now uses the correct logger path.
18+ * The merge by type was made more robust under heavy load, making sure to use the same ` now ` for all dispatches that are checked.
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ dependencies = [
4040 # plugins.mkdocstrings.handlers.python.import)
4141 " frequenz-sdk >= 1.0.0-rc2100, < 1.0.0-rc2200" ,
4242 " frequenz-channels >= 1.6.1, < 2.0.0" ,
43- " frequenz-client-dispatch >= 0.11.0 , < 0.12.0" ,
43+ " frequenz-client-dispatch >= 0.11.1 , < 0.12.0" ,
4444 " frequenz-client-common >= 0.3.2, < 0.4.0" ,
4545 " frequenz-client-base >= 0.11.0, < 0.12.0" ,
4646]
Original file line number Diff line number Diff line change @@ -43,10 +43,29 @@ def started(self) -> bool:
4343 Returns:
4444 True if the dispatch is started, False otherwise.
4545 """
46+ now = datetime .now (tz = timezone .utc )
47+ return self .started_at (now )
48+
49+ def started_at (self , now : datetime ) -> bool :
50+ """Check if the dispatch has started.
51+
52+ A dispatch is considered started if the current time is after the start
53+ time but before the end time.
54+
55+ Recurring dispatches are considered started if the current time is after
56+ the start time of the last occurrence but before the end time of the
57+ last occurrence.
58+
59+ Args:
60+ now: time to use as now
61+
62+ Returns:
63+ True if the dispatch is started
64+ """
4665 if self .deleted :
4766 return False
4867
49- return super ().started
68+ return super ().started_at ( now )
5069
5170 # noqa is needed because of a bug in pydoclint that makes it think a `return` without a return
5271 # value needs documenting
Original file line number Diff line number Diff line change 55
66import logging
77from collections .abc import Mapping
8+ from datetime import datetime , timezone
89from sys import maxsize
910from typing import Any
1011
@@ -41,12 +42,14 @@ def filter(
4142 Keeps stop events only if no other dispatches matching the
4243 strategy's criteria are running.
4344 """
44- if dispatch .started :
45+ now = datetime .now (tz = timezone .utc )
46+
47+ if dispatch .started_at (now ):
4548 _logger .debug ("Keeping start event %s" , dispatch .id )
4649 return True
4750
4851 other_dispatches_running = any (
49- existing_dispatch .started
52+ existing_dispatch .started_at ( now )
5053 for existing_dispatch in dispatches .values ()
5154 if (
5255 self .identity (existing_dispatch ) == self .identity (dispatch )
You can’t perform that action at this time.
0 commit comments