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

Context managed transports #1218

Merged
merged 6 commits into from
Aug 26, 2020
Merged

Context managed transports #1218

merged 6 commits into from
Aug 26, 2020

Conversation

tomchristie
Copy link
Member

@tomchristie tomchristie commented Aug 26, 2020

Closes #1145

Note that once #977 is addressed we'll be able to test the proxies case more elegantly.

We're not being clever here about "ensure other transports still close if an exceptions occurs during __exit__ in one transport". (Or the other fiddly case, of ensuring the __exit__ is called on any already __enter__'d transports, if an exception occurs during __enter__.)

I think we should probably treat that as a follow up, and it's possible that we might only want to do so once #977 is addressed.

I think thats probably an okay approach to take since it's not any worse than our existing behaviour, which anyway doesn't handle "ensure other transports still close if an exceptions occurs during close in one transport", and besides exceptions during transport __enter__/__exit__ are pretty much unrecoverable issues, and it's not really any worse if they happen to potentially leave other transports hanging open.

(Actually having talked through it I'm not event convinced that we should bother handling that case at all, but either way let's talk it through as a follow-up)

httpx/_client.py Outdated Show resolved Hide resolved
httpx/_client.py Outdated Show resolved Hide resolved
tests/client/test_async_client.py Outdated Show resolved Hide resolved
tests/client/test_client.py Outdated Show resolved Hide resolved
tests/client/test_async_client.py Show resolved Hide resolved
tomchristie and others added 4 commits August 26, 2020 11:54
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
@tomchristie
Copy link
Member Author

@florimondmanca Your reviews are always on-point. Wonderful, thank you. ✨🔥✨

Copy link
Member

@florimondmanca florimondmanca left a comment

Choose a reason for hiding this comment

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

💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context Managed Transports
2 participants