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

Modify _drain_helper() to handle parallel calls without race-condition #6028

Merged
merged 4 commits into from
Oct 27, 2021
Merged

Modify _drain_helper() to handle parallel calls without race-condition #6028

merged 4 commits into from
Oct 27, 2021

Conversation

Traktormaster
Copy link
Contributor

What do these changes do?

These changes fix a bug/race-condition on the BaseProtocol's drain-waiter.

Are there changes in behavior for the user?

There are no API or behavioral changes. This should exclusively handle the case of the race-condition when multiple coroutines produce messages to a websocket for example.

Related issue number

This fix is aimed at the #2934 issue directly.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes - Not applicable AFAIK
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the pr
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: "Fix issue with non-ascii contents in doctest text files."

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 1, 2021
aiohttp/base_protocol.py Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Oct 6, 2021

Codecov Report

Merging #6028 (9a17ee5) into master (45c38f2) will increase coverage by 3.39%.
The diff coverage is 100.00%.

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

@@            Coverage Diff             @@
##           master    #6028      +/-   ##
==========================================
+ Coverage   93.32%   96.72%   +3.39%     
==========================================
  Files         102       44      -58     
  Lines       30140     9857   -20283     
  Branches     2696     1593    -1103     
==========================================
- Hits        28129     9534   -18595     
+ Misses       1837      183    -1654     
+ Partials      174      140      -34     
Flag Coverage Δ
unit 96.62% <100.00%> (+3.36%) ⬆️

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

Impacted Files Coverage Δ
aiohttp/base_protocol.py 86.15% <100.00%> (-4.62%) ⬇️
aiohttp/http_websocket.py 98.65% <0.00%> (-0.27%) ⬇️
aiohttp/web_response.py 98.21% <0.00%> (-0.21%) ⬇️
aiohttp/client_reqrep.py 97.86% <0.00%> (-0.16%) ⬇️
aiohttp/helpers.py 96.83% <0.00%> (-0.10%) ⬇️
aiohttp/cookiejar.py 98.78% <0.00%> (-0.06%) ⬇️
aiohttp/web_app.py 97.33% <0.00%> (ø)
aiohttp/typedefs.py 100.00% <0.00%> (ø)
aiohttp/web_protocol.py 86.41% <0.00%> (ø)
... and 73 more

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 45c38f2...cebc7d2. Read the comment docs.

CHANGES/2934.bugfix Outdated Show resolved Hide resolved
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.

OK, got your idea.
Smart.
Thank you.

@asvetlov asvetlov enabled auto-merge (squash) October 27, 2021 15:53
@asvetlov asvetlov merged commit 3eea7b8 into aio-libs:master Oct 27, 2021
@patchback
Copy link
Contributor

patchback bot commented Oct 27, 2021

Backport to 3.8: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.8/3eea7b8dbd90b7ebd4f9f0572323dbee8c13611c/pr-6028

Backported as #6146

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Oct 27, 2021
#6028)

* Modify _drain_helper() to handle parallel calls of _send_frame() without race-condition.

* Update CHANGES/2934.bugfix

* Update 2934.bugfix

Co-authored-by: Andrew Svetlov <[email protected]>
(cherry picked from commit 3eea7b8)
aio-libs-github-bot bot pushed a commit that referenced this pull request Oct 27, 2021
#6028)

* Modify _drain_helper() to handle parallel calls of _send_frame() without race-condition.

* Update CHANGES/2934.bugfix

* Update 2934.bugfix

Co-authored-by: Andrew Svetlov <[email protected]>
@aio-libs-github-bot
Copy link
Contributor

💚 Backport successful

The PR was backported to the following branches:

asvetlov added a commit that referenced this pull request Oct 27, 2021
#6028) (#6147)

* Modify _drain_helper() to handle parallel calls of _send_frame() without race-condition.

* Update CHANGES/2934.bugfix

* Update 2934.bugfix

Co-authored-by: Andrew Svetlov <[email protected]>

Co-authored-by: Nándor Mátravölgyi <[email protected]>
Co-authored-by: Andrew Svetlov <[email protected]>
asvetlov pushed a commit that referenced this pull request Oct 27, 2021
#6028) (#6146)

* Modify _drain_helper() to handle parallel calls of _send_frame() without race-condition.

* Update CHANGES/2934.bugfix

* Update 2934.bugfix

Co-authored-by: Andrew Svetlov <[email protected]>
(cherry picked from commit 3eea7b8)

Co-authored-by: Nándor Mátravölgyi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants