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

Stricter enforcement of client lifespan styles. #1800

Merged
merged 2 commits into from
Aug 13, 2021

Conversation

tomchristie
Copy link
Member

When using a client, the expectation is that users should use one of the two following styles...

with httpx.Client() as client:
    ...

Or...

client = httpx.Client()
...

This pull request introduces a little bit of guarding around the opening of a client with block in order to enforce that unexpected usages mixing the two styles don't occur, so that we can't...

  • Reopen a client once it's been closed.
  • Enter into a client with block more than once.

Nailing down the possible usages here should just help guard against odd unexpected states.

Closes #1615

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.

Stricter enforcement around client scoping.
1 participant