Skip to content

Commit 6e8d725

Browse files
committed
ringbuf_queue: Add asynchronous get() method.
1 parent 69bc2d4 commit 6e8d725

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

v3/docs/EVENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,9 @@ Synchronous methods (immediate return):
513513
Asynchronous methods:
514514
* `put` Arg: the object to put on the queue. If the queue is full, it will
515515
block until space is available.
516-
516+
* `get` Return an object from the queue. If empty, block until an item is
517+
available.
518+
517519
Retrieving items from the queue:
518520

519521
The `RingbufQueue` is an asynchronous iterator. Results are retrieved using

v3/primitives/ringbuf_queue.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def __aiter__(self):
6464
return self
6565

6666
async def __anext__(self):
67+
return await self.get()
68+
69+
async def get(self):
6770
while self.empty(): # Empty. May be more than one task waiting on ._evput
6871
await self._evput.wait()
6972
r = self._q[self._ri]

0 commit comments

Comments
 (0)