Skip to content
This repository was archived by the owner on Nov 13, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions utilities/workers/queue_proxy_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
class QueueProxyWrapper:
"""
Wrapper for an underlying queue proxy which also stores maxsize.
`maxsize <= 0` means the queue has infinite size.
"""

__QUEUE_TIMEOUT = 0.1 # seconds
Expand All @@ -29,8 +30,7 @@ def fill_queue_with_sentinel(self, timeout: float = 0.0) -> None:
timeout = self.__QUEUE_TIMEOUT

try:
self.queue.put(None, timeout=timeout)
for _ in range(1, self.maxsize):
for _ in range(self.maxsize):
self.queue.put(None, timeout=timeout)
except queue.Full:
return
Expand All @@ -45,7 +45,8 @@ def drain_queue(self, timeout: float = 0.0) -> None:
timeout = self.__QUEUE_TIMEOUT

try:
self.queue.get(timeout=timeout)
for _ in range(self.maxsize):
self.queue.get(timeout=timeout)
except queue.Empty:
return

Expand Down
Loading