Skip to content

Create a task per request handling. - #3442

Merged
asvetlov merged 6 commits into
masterfrom
task-per-request
Dec 9, 2018
Merged

asvetlov merged 6 commits into
masterfrom
task-per-request

Conversation

@asvetlov

@asvetlov asvetlov commented Dec 8, 2018

Copy link
Copy Markdown
Member

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.
Comment thread tests/test_web_protocol.py Resolved

@kxepal kxepal left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

Looks good.

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

Perhaps with an example of how to use it.

@asvetlov

asvetlov commented Dec 9, 2018

Copy link
Copy Markdown
Member Author

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

@samuelcolvin

Copy link
Copy Markdown
Member

I guess.

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

@codecov-io

codecov-io commented Dec 9, 2018 •

Copy link
Copy Markdown

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

asvetlov commented Dec 9, 2018

Copy link
Copy Markdown
Member Author

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

lock Bot commented Dec 9, 2019

Copy link
Copy Markdown

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
@pyba-chronographer pyba-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