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 clean fix for cancelation on 3.9+. #235

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use function.
  • Loading branch information
Dreamsorcerer committed Sep 3, 2021
commit 6e985e15a5156d1c716dd2b08210bcfbdbd85e2c
6 changes: 4 additions & 2 deletions async_timeout/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@ def _do_enter(self) -> None:

def _do_exit(self, exc_type: Type[BaseException], exc_val: BaseException) -> None:
if sys.version_info >= (3, 9):
was_timeout_cancelled = lambda: _SENTINEL in exc_val.args
def was_timeout_cancelled():
return _SENTINEL in exc_val.args
else:
was_timeout_cancelled = lambda: self._state == _State.TIMEOUT
def was_timeout_cancelled():
return self._state == _State.TIMEOUT
if exc_type is asyncio.CancelledError and was_timeout_cancelled():
self._timeout_handler = None
raise asyncio.TimeoutError
Expand Down