aiohttp icon indicating copy to clipboard operation
aiohttp copied to clipboard

Add runner.serve_forever()

Open vsmaxim opened this issue 2 years ago • 2 comments

What do these changes do?

This is a continuation of work from #4378. I've dropped cleanup call on serve_forever() task cancellation and updated the documentation accordingly.

Are there changes in behavior for the user?

No.

Related issue number

#2746

Original attempt from asvetlov: https://github.com/aio-libs/aiohttp/compare/master...server_forever

Checklist

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

vsmaxim avatar Oct 09 '23 18:10 vsmaxim

Codecov Report

Attention: Patch coverage is 94.28571% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 97.36%. Comparing base (4601183) to head (b05fcaa). Report is 480 commits behind head on master.

Files Patch % Lines
aiohttp/web_runner.py 83.33% 1 Missing and 1 partial :warning:
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #7688    +/-   ##
========================================
  Coverage   97.36%   97.36%            
========================================
  Files         106      106            
  Lines       31541    31661   +120     
  Branches     3593     3625    +32     
========================================
+ Hits        30709    30826   +117     
- Misses        630      631     +1     
- Partials      202      204     +2     
Flag Coverage Δ
CI-GHA 97.28% <94.28%> (+<0.01%) :arrow_up:
OS-Linux 96.95% <94.28%> (+<0.01%) :arrow_up:
OS-Windows 95.42% <94.28%> (+0.02%) :arrow_up:
OS-macOS 96.61% <94.28%> (+0.01%) :arrow_up:
Py-3.10.11 95.35% <94.28%> (+0.02%) :arrow_up:
Py-3.10.13 96.81% <94.28%> (+<0.01%) :arrow_up:
Py-3.11.5 96.49% <94.28%> (-0.03%) :arrow_down:
Py-3.8.10 95.32% <94.28%> (+0.02%) :arrow_up:
Py-3.8.18 96.74% <94.28%> (+<0.01%) :arrow_up:
Py-3.9.13 95.31% <94.28%> (+0.02%) :arrow_up:
Py-3.9.18 96.77% <94.28%> (+<0.01%) :arrow_up:
Py-pypy7.3.11 96.26% <94.28%> (-0.03%) :arrow_down:
VM-macos 96.61% <94.28%> (+0.01%) :arrow_up:
VM-ubuntu 96.95% <94.28%> (+<0.01%) :arrow_up:
VM-windows 95.42% <94.28%> (+0.02%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 09 '23 19:10 codecov[bot]

Sorry for taking so long to look at this. I have a few questions about the implementation and expected behaviour:

  • The original attempt ran cleanup on cancellation. Should this still happen? Seems it would match the asyncio.Server behaviour which says "Cancellation of serve_forever task causes the server to be closed."
    • I see @asvetlov suggested we do an async context manager for this one instead, so I guess the current version is correct. Will need a second PR to add the context manager though.
  • The original also checks if there's any sites, should we include that check?
  • Along those same lines, should we call Site.start() for each site, so the user doesn't need to call that themselves? This would match the asyncio.Server behaviour which calls Server.start_serving() from within Server.serve_forever().
  • Should an explicit call to Runner.cleanup() cancel the future in serve_forever()? This would match asyncio.Server.close() which cancels the future.

Dreamsorcerer avatar Feb 27 '24 16:02 Dreamsorcerer