Skip to content

Max concurrent stream improvements - #90

Merged
lovelydinosaur merged 1 commit into
masterfrom
max-concurrent-stream-improvements
May 14, 2020
Merged

Max concurrent stream improvements#90
lovelydinosaur merged 1 commit into
masterfrom
max-concurrent-stream-improvements

Conversation

@lovelydinosaur

Copy link
Copy Markdown
Contributor

Right, there was some stuff I didn't quite get correct in #89

Absurdly I'd forgotten to use http2=True in my testings. This is the script I'm using now for this...

importasyncioimporthttpcoreasyncdefmain():
asyncwithhttpcore.AsyncConnectionPool(http2=True) asclient:
awaitasyncio.gather(*[request(client, idx) foridxinrange(1000)])
asyncdefrequest(client, idx):
http_version, status_code, reason_phrase, headers, stream=awaitclient.request(
method=b'GET',
url=(b'https', b'example.org', 443, b'/'),
headers=[(b'host', b'example.org:443')]
)
try:
body=b''.join([chunkasyncforchunkinstream])
finally:
awaitstream.aclose()
asyncio.run(main())

The changes here are:

  • We need to use the local settings to determine how many concurrent streams we can issue, not the remote settings.
  • The stream_id = self.h2_state.get_next_available_stream_id() needs to be part of the semaphore-limited wrapped code, or else it stops incrementing once we've hit the concurrency limit. As a result I've moved the wrapping layer out from AsyncHTTP2Stream onto AsyncHTTP2Connection instead.

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

Nice! 👍

@lovelydinosaur
lovelydinosaur merged commit 30847a0 into masterMay 14, 2020
@lovelydinosaur
lovelydinosaur deleted the max-concurrent-stream-improvements branch May 14, 2020 15:44
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lovelydinosaur@yeraydiazdiaz