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

Could async_q.get() support a timeout? #240

Closed
simonw opened this issue Feb 24, 2020 · 1 comment
Closed

Could async_q.get() support a timeout? #240

simonw opened this issue Feb 24, 2020 · 1 comment

Comments

@simonw
Copy link
Contributor

simonw commented Feb 24, 2020

Python's queue.Queue.get() takes an optional timeout, and will block for up to that amount of time.

Python's asyncio.Queue.get() doesn't support this option.

I know Janus is attempting to closely initiate these APIs, but would it be feasible (and a good idea) for Janus to provide a timeout option even when reading from the async queue?

I would love to be able to do this:

try:
    item = await queue.async_q.get(timeout=0.5)
except Empty:
    # ...
@achimnol
Copy link
Member

achimnol commented Mar 1, 2020

I think you could add timeout using async-timeout, which provides more fine-grained control of timeouts as a context-manager style.

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

3 participants