-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ring buffer gap cleanup code #578
Changes from all commits
8bc19bc
79c373f
38ac7fb
d8eaaeb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,17 +328,24 @@ def _cleanup_gaps(self) -> None: | |
self._gaps = sorted(self._gaps, key=lambda x: x.start.timestamp()) | ||
|
||
i = 0 | ||
while i < len(self._gaps) - 1: | ||
while i < len(self._gaps): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Def should have a test for this and the other new case There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a case for the new case at least There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added another test case for the "old" bug. |
||
w_1 = self._gaps[i] | ||
w_2 = self._gaps[i + 1] | ||
if i < len(self._gaps) - 1: | ||
w_2 = self._gaps[i + 1] | ||
else: | ||
w_2 = None | ||
|
||
# Delete out-of-date gaps | ||
if w_1.end <= self._datetime_oldest: | ||
del self._gaps[i] | ||
# Update start of gap if it's rolled out of the buffer | ||
elif w_1.start < self._datetime_oldest: | ||
self._gaps[i].start = self._datetime_oldest | ||
# If w2 is a subset of w1 we can delete it | ||
elif w_1.start <= w_2.start and w_1.end >= w_2.end: | ||
elif w_2 and w_1.start <= w_2.start and w_1.end >= w_2.end: | ||
del self._gaps[i + 1] | ||
# If the gaps are direct neighbors, merge them | ||
elif w_1.end >= w_2.start: | ||
elif w_2 and w_1.end >= w_2.start: | ||
w_1.end = w_2.end | ||
del self._gaps[i + 1] | ||
else: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are a bad bad boy. You should have first approved and merged #574.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wops