Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
linw1995 opened this issue Oct 14, 2020 · 3 comments
Closed

Comments

@linw1995
Copy link
Contributor

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
@asvetlov
Copy link
Member

Agree. Would you provide a pull request with the fix?

@linw1995
Copy link
Contributor Author

Agree. Would you provide a pull request with the fix?

@asvetlov Yes. I create a pull request to fix this. #295

@asvetlov
Copy link
Member

Fixed by #295

@asvetlov asvetlov reopened this Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants