Skip to content

Issue a new connection if HTTP/2 stream IDs expire. - #453

Closed
gdhameeja wants to merge 3 commits into
encode:masterfrom
gdhameeja:feature-283_1
Closed

gdhameeja wants to merge 3 commits into
encode:masterfrom
gdhameeja:feature-283_1

Conversation

@gdhameeja

Copy link
Copy Markdown
Contributor

Fixes #283
Create new HTTPConnection if stream ids expire. The making of new connection is done in ConnectionPool instead of in HTTPConnection.

@gdhameeja

gdhameeja commented Oct 6, 2019 •

Copy link
Copy Markdown
Contributor Author

@florimondmanca Here is the new PR for #283 where connections are being opened in the connection pool. Although the test doesn't work even now. After setting up the MockHTTP2Server how do I make requests to it with the ConnectionPool?

@yeraydiazdiaz

Copy link
Copy Markdown
Contributor

Hi @gdhameeja, thanks for your PR.

Your branch includes a very large TAGS file which I presume you accidentally commited in that last merging of master onto your branch.

I suggest creating a new branch from master and applying those changes to ensure a clean PR.

@florimondmanca

Copy link
Copy Markdown
Contributor

An alternative to revert without creating a new PR is to edit the commit:

$ rm -rf TAGS
$ git add -A
$ git commit --amend --no-edit
$ git push --force

Seems like TAGS is an emacs/vim thing (source). Should we add it to .gitignore?

@sethmlarson

Copy link
Copy Markdown
Contributor

No, editor specific files should be in your own personal gitignore file.
@gdhameeja I recommend looking at this: https://gist.github.com/subfuzion/db7f57fff2fb6998a16c

@lovelydinosaur lovelydinosaur 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.

Good start! Coupla comments here. (Plus agreed with others re. removing the TAGS being neccessary)

Comment thread httpx/dispatch/connection_pool.py Outdated
Comment thread httpx/dispatch/connection_pool.py Outdated
@lovelydinosaur lovelydinosaur changed the title Feature 283 #283 Issue a new connection if HTTP/2 stream IDs expire. Oct 7, 2019
@lovelydinosaur

Copy link
Copy Markdown
Member

"An alternative to revert without creating a new PR is to edit the commit"

We squash and merge all PRs, so I don't think there's any need to remove it from the history. Just git delete it and we're good with keeping the rest of the pull request as it is.

@gdhameeja

Copy link
Copy Markdown
Contributor Author

Awaiting review.

@florimondmanca

Copy link
Copy Markdown
Contributor

@gdhameeja The test is failing because MockHTTP2Server doesn't have an url — see the CI build logs.

This is looking okay to me in principle, but the mock test isn't convincing me that this will effectively allow HTTPX to handle the case in the wild. Have you thought of a way we could (manually?) test this against a live server?

@florimondmanca florimondmanca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a nit, otherwise the code looks good to me. :)

Comment thread httpx/dispatch/connection_pool.py Outdated
Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
@florimondmanca florimondmanca added the http/2 Issues and PRs related to HTTP/2 label Oct 19, 2019
@gdhameeja

Copy link
Copy Markdown
Contributor Author

@florimondmanca Currently I am unable to think of a way to test this manually. I might be wrong here but someone mentioned that we can have 2^31 labelled stream ids. With that condition, I think it'd be hard to test this manually.

@gdhameeja

Copy link
Copy Markdown
Contributor Author

@florimondmanca @sethmlarson @tomchristie Awaiting review.

@florimondmanca florimondmanca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are a few issues I hadn't seen before, I left a few hints on how to resolve them. We need to get the build to pass before considering merging this. There have been some changes to the build setup (e.g. Python 3.8 is now mandatory) so you could rebase your changes from master to get the most up to date version?

Comment on lines +128 to +131
except NewConnectionRequired:
return await self.send(
request=request, verify=verify, cert=cert, timeout=timeout
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems this block will actually never run, because it is shadowed by the catch-all block for BaseException — we need to move it above the one for BaseException.

server.conn.HIGHEST_ALLOWED_STREAM_ID = 1

async with httpx.ConnectionPool(backend=backend) as http:
response = await http.request("GET", server.url)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The mock server has no .url attribute, which makes the build fail. I think you can use anything here, since we don't make real requests, so e.g. "/".

@florimondmanca

Copy link
Copy Markdown
Contributor

Sorry to see that this PR has be dragging a bit, I'll close it for housekeeping purposes but we can obviously revisit later with a clean slate. Thanks!

gdhameeja pushed a commit to gdhameeja/httpx that referenced this pull request Nov 24, 2019
Kludex referenced this pull request in pydantic/httpx2 May 11, 2026
Bumps [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) from 0.15.1 to 0.16.0.
- [Release notes](https://github.com/pytest-dev/pytest-asyncio/releases)
- [Commits](pytest-dev/pytest-asyncio@v0.15.1...v0.16.0)

---
updated-dependencies:
- dependency-name: pytest-asyncio
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tom Christie <tom@tomchristie.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http/2 Issues and PRs related to HTTP/2

Development

Successfully merging this pull request may close these issues.

Open new HTTP/2 connections when stream space is exhausted.

5 participants