Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def join(self) -> None:
"""Block until all items in the queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the
queue. The count goes down whenever a consumer calls task_done() to
indicate that the item was retrieved and all work on it is complete.
When the count of unfinished tasks drops to zero, join() unblocks.
"""
while True:
with self._parent._sync_mutex:
if self._parent._unfinished_tasks == 0:
break
await self._parent._finished.wait()
class PriorityQueue(Queue[T]):
'''Variant of Queue that retrieves open entries in priority order
(lowest first).
Entries are typically tuples of the form: (priority number, data).
'''
def _init(self, maxsize: int) -> None:
self._heap_queue = [] # type: List[T]
def _qsize(self) -> int:
return len(self._heap_queue)
def _put(self, item: T) -> None:
heappush(self._heap_queue, item)