Skip to content
Draft
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
5 changes: 3 additions & 2 deletions async_batcher/batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ async def process(self, item: T) -> S:
self._current_task = asyncio.get_running_loop().create_task(self.run())
logging.debug(item)
future = asyncio.get_running_loop().create_future()
if self._queue.full():
try:
self._queue.put_nowait(self.QueueItem(item, future))
except asyncio.QueueFull:
raise QueueFullException("The queue is full, cannot process more items at the moment.")
await self._queue.put(self.QueueItem(item, future))
await future
return future.result()

Expand Down
Loading