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

ClientSession inside an aiohttp Server does not support connection pooling #2072

Closed
alexmac opened this issue Jul 9, 2017 · 6 comments
Closed
Labels
documentation Improvements or additions to documentation outdated
Milestone

Comments

@alexmac
Copy link
Contributor

alexmac commented Jul 9, 2017

I've got a aiohttp server that makes multiple http requests to other services in response to its inbound requests, I want to use a ClientSession for each inbound request to handle any cookie state that may be needed across the downstream requests it makes - but this means my server makes no use of connection-pooling/keep-alive when making downstream requests.

I could share a single ClientSession across all inbound requests, but then cookie/header state within the ClientSession would be re-used across inbound requests, which would not be correct. I could perhaps create a SharedClientSession object that handled switching between cookies/headers with a single underlying ClientSession, but that seems like I'm fighting the system.

Is there a supported way to do this? The most elegant way I can imagine would be a single ClientSession per inbound request with a global tcpconnector - except the ClientSession takes ownership and closes it, making it impossible to use in this way.

@fafhrd91
Copy link
Member

fafhrd91 commented Jul 9, 2017

client session accepts connector_owner parameter.

@asvetlov seems we need to document connector_owner parameter.

@asvetlov
Copy link
Member

asvetlov commented Jul 9, 2017

Hmmm. Maybe. Not only mention the param in reference but provide usage example.
Sorry, I'm at EuroPython and have very limited free time.

@alexmac
Copy link
Contributor Author

alexmac commented Jul 9, 2017

My bad for not reading the code, glad it's implemented the way I wanted! But some doc improvements would be nice

@alexmac alexmac closed this as completed Jul 9, 2017
@asvetlov asvetlov reopened this Jul 9, 2017
@asvetlov
Copy link
Member

asvetlov commented Jul 9, 2017

Keep open until doc update.

@asvetlov
Copy link
Member

See also #2067

@fafhrd91 fafhrd91 added this to the 2.3.0 milestone Jul 17, 2017
@fafhrd91 fafhrd91 added the documentation Improvements or additions to documentation label Jul 17, 2017
@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.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation outdated
Projects
None yet
Development

No branches or pull requests

3 participants