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

Correct request.app context (for handlers not just middlewares) #2577

Merged
merged 3 commits into from
Dec 4, 2017

Conversation

popravich
Copy link
Member

This is an update to #2550
_fix_request_current_app middleware was added if application had any middlewares.
Now it is yielded unconditionally to set proper context for handlers as well.

@popravich
Copy link
Member Author

@asvetlov , I'm not sure about target branch — should it be master or some bugfix branch?

@asvetlov
Copy link
Member

asvetlov commented Dec 4, 2017

I'll cherry-pick to 2.3 myself

@codecov-io
Copy link

codecov-io commented Dec 4, 2017

Codecov Report

Merging #2577 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2577      +/-   ##
==========================================
- Coverage   97.71%   97.71%   -0.01%     
==========================================
  Files          36       36              
  Lines        7229     7228       -1     
  Branches     1262     1261       -1     
==========================================
- Hits         7064     7063       -1     
  Misses         58       58              
  Partials      107      107
Impacted Files Coverage Δ
aiohttp/web.py 97.86% <100%> (-0.01%) ⬇️

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 e0bb501...3dac5b6. Read the comment docs.

@asvetlov asvetlov merged commit a910801 into master Dec 4, 2017
@asvetlov asvetlov deleted the nested_apps_with_middleware branch December 4, 2017 16:32
@asvetlov
Copy link
Member

asvetlov commented Dec 4, 2017

thanks!

asvetlov pushed a commit that referenced this pull request Dec 4, 2017
* yield _fix_request_current_app middleware uncoditionally; update test; (see #2550)

* Add change notes
@pfreixes
Copy link
Contributor

Just FYI this fix impacted with a loss btw 5%-10% of the performance, we should try to make it in some way that does not reuse the middlewares code to setup also the current app when there are no middlewares installed.

@amirouche
Copy link

Does it make sens to optimize for the case where there is no middleware?

@asvetlov
Copy link
Member

The check should analyze not only middlewares but nested applications also.
Pull Request is welcome!

@popravich
Copy link
Member Author

The performance loss might be introduced by making Request.app a real property and not cached one.
So I guess optimizing for the case when there are no middlewares might not bring those percents back.

pfreixes added a commit that referenced this pull request Dec 28, 2017
Fixes performance issue introduced by #2577, boosting from 8K req/sec
to almost 9K req/sec.

If there are no middlewares installed by the user the attribute
`request._match_info.current_app` already looks at to the right app,
this is by design.
pfreixes added a commit that referenced this pull request Dec 28, 2017
)

* Skip middleware code when there are no user middlewares installed

Fixes performance issue introduced by #2577, boosting from 8K req/sec
to almost 9K req/sec.

If there are no middlewares installed by the user the attribute
`request._match_info.current_app` already looks at to the right app,
this is by design.
@lock
Copy link

lock bot commented Oct 28, 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].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

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

Successfully merging this pull request may close these issues.

5 participants