Dev Helpers
← Back

Check whether an async queue is full

Check whether an async queue is full in Python.

Open this example in the interactive library

Source code

import asyncio
async def main():
    queue = asyncio.Queue(maxsize=1)
    queue.put_nowait('first')
    try:
        queue.put_nowait('second')
    except asyncio.QueueFull:
        print('Full:', queue.get_nowait())
asyncio.run(main())

Sample output

Full: first