Skip to content

join() calls should raise RuntimeError while the queue is closing or closed. #294

@linw1995

Description

@linw1995

Recently discover that it can call q.join() on a closed queue. And I notice the q.join() will block forever even after the queue being closed.

It is better that it should check parent queue is closing or not, while q.join() calling or to be called.

The q.join() calls should raise RuntimeError, when q.join() calls on a closed queue or when closing a queue while q.join() is calling.

import janus


async def join_after_closing():
    q = jauns.Queue()
    await q.async_q.put("boo")
    q.close()
    await q.async_q.join()  # blocks forever


async def close_after_join():
    q = jauns.Queue()
    await q.async_q.put("boo")
    task = janus.ensure_future(q.async_q.join())
    await asyncio.sleep(1) # ensure the task is blocking
    q.close()
    await task  # blocks forever too

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions