feat(perception): qualify E33 worker shadow
This commit is contained in:
@@ -592,17 +592,21 @@ class LatestWinsQueue[T]:
|
||||
self._dropped_superseded = 0
|
||||
self._closed = False
|
||||
|
||||
def publish(self, item: T) -> None:
|
||||
def publish(self, item: T) -> T | None:
|
||||
"""Publish fresh work and return the evicted oldest item, if any."""
|
||||
|
||||
with self._condition:
|
||||
if self._closed:
|
||||
raise RuntimeError("cannot publish to a closed latest-wins queue")
|
||||
dropped: T | None = None
|
||||
if len(self._items) == self._capacity:
|
||||
self._items.popleft()
|
||||
dropped = self._items.popleft()
|
||||
self._dropped_overflow += 1
|
||||
self._items.append(item)
|
||||
self._published += 1
|
||||
self._maximum_depth = max(self._maximum_depth, len(self._items))
|
||||
self._condition.notify()
|
||||
return dropped
|
||||
|
||||
def take_next(self, timeout: float | None = None) -> T | None:
|
||||
with self._condition:
|
||||
|
||||
Reference in New Issue
Block a user