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

Create a task per request handling. #3442

Merged
merged 6 commits into from
Dec 9, 2018
Merged

Create a task per request handling. #3442

merged 6 commits into from
Dec 9, 2018

Conversation

asvetlov
Copy link
Member

@asvetlov asvetlov commented Dec 8, 2018

Fixes #3406

A separate task for every request doesn't produce any performance degradation on benchmarks.

Tests update is needed to wait for not only a task started by connection_made() but also a nested task.

Fixes #3406

A separate task for every request doesn't produce any performance degradation on benchmarks.

Tests update is needed to wait not only a task started by connection_made() but also a nexted task.
tests/test_web_protocol.py Outdated Show resolved Hide resolved
Copy link
Member

@kxepal kxepal left a comment

Choose a reason for hiding this comment

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

LGFM. Indeed, it doesn't affects performance (or it does, but those numbers get lost in statistical error).

@webknjaz webknjaz closed this Dec 9, 2018
@webknjaz webknjaz reopened this Dec 9, 2018
@samuelcolvin
Copy link
Member

Looks good.

We should document this and state prominently that aiohttp supports ContextVar?

Perhaps with an example of how to use it.

@asvetlov
Copy link
Member Author

asvetlov commented Dec 9, 2018

@samuelcolvin what docs part do you suggest?
A chapter in web_quickstart.rst maybe?

@samuelcolvin
Copy link
Member

I guess.

Not sure if really matters, just if someone searches "aiohttp ContextVar" they should get a result in docs.

@codecov-io
Copy link

codecov-io commented Dec 9, 2018

Codecov Report

Merging #3442 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3442      +/-   ##
==========================================
+ Coverage   97.93%   97.93%   +<.01%     
==========================================
  Files          44       44              
  Lines        8538     8539       +1     
  Branches     1378     1378              
==========================================
+ Hits         8362     8363       +1     
  Misses         72       72              
  Partials      104      104
Impacted Files Coverage Δ
aiohttp/web_protocol.py 92.2% <100%> (+0.02%) ⬆️

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 8103b8c...05be172. Read the comment docs.

@asvetlov
Copy link
Member Author

asvetlov commented Dec 9, 2018

I've started to write a doc but found that there are questions about contextvars initialization:

  • Where is safe to set up a context?
  • How it works with the context modification code in Application.on_startup()?
  • The PR creates a context copy for every request processing, sure. But what is the original context source?

Let me merge the PR as is and solve the questions in separate one (along with documentation update). Maybe run_app() code should be modified as well, I need to check.

@asvetlov asvetlov merged commit 9997cae into master Dec 9, 2018
@asvetlov asvetlov deleted the task-per-request branch December 9, 2018 22:05
@lock
Copy link

lock bot commented Dec 9, 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 Dec 9, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Dec 9, 2019
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Dec 9, 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 enhancement outdated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ContextVar support?
6 participants