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

Add an expired property #11

Closed
asvetlov opened this issue Aug 16, 2017 · 3 comments
Closed

Add an expired property #11

asvetlov opened this issue Aug 16, 2017 · 3 comments

Comments

@asvetlov
Copy link
Member

  1. Context manager should return itself from __enter__.
  2. expired property should return True if timeout expired.

The change allows to figure out is asyncio.TimeoutError was raised by context manager itself or internal code, e.g.

try:
    async with timeout(1.0) as cm:
        await fetch()
except asyncio.TimeoutError:
    if cm.expired:
         # top level timeout
    else:
         # `fetch()` raised timeout itself

@hellysmile we discussed the change offline.
Do you agree with proposed API?

@hellysmile
Copy link
Member

Looks perfect. Another way is just bool(cm), not sure is it clear or nor

@asvetlov
Copy link
Member Author

Explicit property is better I believe.

@asvetlov
Copy link
Member Author

Fixed by #16

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