Skip to content

Check for proper method to close stream in asynchronous case - #1316

Merged
florimondmanca merged 1 commit into
encode:masterfrom
daa:check-proper-async-close-method
Sep 24, 2020
Merged

Check for proper method to close stream in asynchronous case#1316
florimondmanca merged 1 commit into
encode:masterfrom
daa:check-proper-async-close-method

Conversation

@daa

@daadaa commented Sep 23, 2020

Copy link
Copy Markdown
Contributor

Asynchronous httpcore streams do not have close() method, they provide aclose(). Fixes #1315 .

@daa

daa commented Sep 23, 2020

Copy link
Copy Markdown
ContributorAuthor

To my mind such attribute checking is rather dubious because if stream must be closed then method to close it is part of its interface and thus all wrappers, mocks or substitutions must to implement it even if they are not required to be closed.

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

Thanks!

@florimondmanca

Copy link
Copy Markdown
Contributor

To my mind such attribute checking is rather dubious

I'd tend to agree yup, since the AsyncByteStream and SyncByteStream interface, documented here: https://www.encode.io/httpcore/api/, specify a .aclose() and .close() method respectively. Happy to consider removing this attribute checking as a follow-up!

@florimondmanca
florimondmanca merged commit 78afd08 into encode:masterSep 24, 2020
@florimondmancaflorimondmanca mentioned this pull request Sep 24, 2020
@lovelydinosaur

Copy link
Copy Markdown
Member

Happily we'll be moving away from the stream .close() interface anyways.

Once we're treating HTTPTransport.request() as a context manager byte streams will just be either Iterable[byte] or AsyncIterable[byte]. (See #1274, encode/httpcore#145)

@daa
daa deleted the check-proper-async-close-method branch September 24, 2020 12:47
@daa

daa commented Sep 24, 2020

Copy link
Copy Markdown
ContributorAuthor

Thank you very much!

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.

Async client does not close underlying stream thus leaving connection active which leads to hitting pool limit

3 participants

@daa@florimondmanca@lovelydinosaur