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

Fix RuntimeError in _sendfile_cb #3370

Closed
wants to merge 3 commits into from
Closed

Conversation

awarecan
Copy link
Contributor

@awarecan awarecan commented Oct 30, 2018

What do these changes do?

Under some circumstances, a Runtime Error RuntimeError: File descriptor 36 is used by transport <ReadUnixTransport closed=False reading=True 0x7f9c51da9d48> will be raise.

This change try to fix it by check if task has been canceled before remove stream writer.

I have never met this issue personally, so I won't be able to write a case to reproduce issue. However this patch has been published in home-assistant/core#12832 (comment) and got positive responses from users who had this issue.

Are there changes in behavior for the user?

Related issue number

fixes #1893

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • 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."

@asvetlov
Copy link
Member

Could you go further and rewrite the code by using add_done_callback like https://github.com/python/cpython/blob/master/Lib/asyncio/unix_events.py#L319-L420 ?

asyncio code is overcomplicated a little to update filepos properly, aiohttp can skip this logic. But you can borrow the cancellation callback and its registration.

@awarecan
Copy link
Contributor Author

I feel little uncomfortable to do such refactoring since I won't be able to reproduce the issue.

@codecov-io
Copy link

codecov-io commented Oct 30, 2018

Codecov Report

Merging #3370 into master will decrease coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3370      +/-   ##
==========================================
- Coverage   97.97%   97.93%   -0.04%     
==========================================
  Files          44       44              
  Lines        8482     8482              
  Branches     1378     1378              
==========================================
- Hits         8310     8307       -3     
- Misses         73       75       +2     
- Partials       99      100       +1
Impacted Files Coverage Δ
aiohttp/web_fileresponse.py 97.51% <100%> (ø) ⬆️
aiohttp/tcp_helpers.py 90% <0%> (-6.67%) ⬇️
aiohttp/client_reqrep.py 97.28% <0%> (-0.16%) ⬇️

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 a0470ad...272980e. Read the comment docs.

@asvetlov
Copy link
Member

asvetlov commented Nov 7, 2018

Superseded by #3383

@asvetlov asvetlov closed this Nov 7, 2018
@lock
Copy link

lock bot commented Nov 7, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Nov 7, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 7, 2019
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Nov 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bot:chronographer:provided There is a change note present in this PR outdated sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConnectionResetError when close browser, but not all static files was fetch
4 participants