Skip to content
New issue

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

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

Already on GitHub? # to your account

Tests and partial fix for suppressing cancellations. #230

Merged
merged 10 commits into from
Sep 3, 2021

Conversation

Dreamsorcerer
Copy link
Member

@Dreamsorcerer Dreamsorcerer commented Aug 30, 2021

Partially fixes #229.

I don't really see any way to get enough information to fully fix this, not really sure how best to proceed.

For an overview of why this is a serious problem, see: #229 (comment)

@Dreamsorcerer Dreamsorcerer changed the title Setup tests and partial fix for overruling cancellations. Tests and partial fix for suppressing cancellations. Aug 30, 2021
Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -198,6 +198,8 @@ def _do_exit(self, exc_type: Type[BaseException]) -> None:
return None

def _on_timeout(self, task: "asyncio.Task[None]") -> None:
if task._fut_waiter and task._fut_waiter.cancelled(): # type: ignore[attr-defined] # noqa: E501
Copy link
Member

@asvetlov asvetlov Sep 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hack looks dangerous and potentially not future compatible; while I don't see a better solution.
For Python 3.9+ task.cancel(SENTINEL) variant can be used though to filter out all cancellation events not sent by async_timeout library itself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think putting a 3.9+ fix in would be acceptable, as I don't see a good way to do this otherwise.

@codecov
Copy link

codecov bot commented Sep 2, 2021

Codecov Report

Merging #230 (7e136a2) into master (7e088ce) will decrease coverage by 1.86%.
The diff coverage is 0.00%.

❗ Current head 7e136a2 differs from pull request most recent head e7d4620. Consider uploading reports for the commit e7d4620 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##            master     #230      +/-   ##
===========================================
- Coverage   100.00%   98.13%   -1.87%     
===========================================
  Files            1        1              
  Lines          105      107       +2     
  Branches        15       16       +1     
===========================================
  Hits           105      105              
- Misses           0        1       +1     
- Partials         0        1       +1     
Flag Coverage Δ
unit 96.26% <0.00%> (-1.84%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
async_timeout/__init__.py 98.13% <0.00%> (-1.87%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e088ce...e7d4620. Read the comment docs.

@asvetlov
Copy link
Member

asvetlov commented Sep 3, 2021

Ok, let me merge and make a new release

@asvetlov asvetlov merged commit 3d235b7 into master Sep 3, 2021
@asvetlov asvetlov deleted the fix-cancel-overrule branch September 3, 2021 11:13
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aiohttp swallows asyncio.CancelledError during connection timeout
2 participants