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

asyncio: Don't wait for the stream to close #640

Merged
merged 2 commits into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions httpx/concurrency/asyncio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import functools
import ssl
import sys
import typing

from ..config import Timeout
Expand Down Expand Up @@ -162,9 +161,14 @@ def is_connection_dropped(self) -> bool:
return self.stream_reader.at_eof()

async def close(self) -> None:
# NOTE: StreamWriter instances expose a '.wait_closed()' coroutine function,
# but using it has caused compatibility issues with certain sites in
# the past (see https://github.com/encode/httpx/issues/634), which is
# why we don't call it here.
# This is fine, though, because '.close()' schedules the actual closing of the
# stream, meaning that at best it will happen during the next event loop
# iteration, and at worst asyncio will take care of it on program exit.
self.stream_writer.close()
if sys.version_info >= (3, 7):
await self.stream_writer.wait_closed()


class PoolSemaphore(BasePoolSemaphore):
Expand Down