Skip to content
Myr

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

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Don't wait for stream_writer to close * Add comment on why wait_closed() is not called

authored by Florimond Manca · committed by Tom Christie · parent 4bb69e3 · Browse files · 1 file+7 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−3 removed

  • other:+7 added−3 removed

1 file+7 added−3 removed

modified:httpx/concurrency/asyncio.py+7 added-3 removed
1import asyncio2import functools3import ssl4import sys4import typing56from ..config import Timeout7from ..exceptions import ConnectTimeout, PoolTimeout, ReadTimeout, WriteTimeout
152 unmodified lines
160161 return self.stream_reader.at_eof()162163 async def close(self) -> None:164 # NOTE: StreamWriter instances expose a '.wait_closed()' coroutine function,165 # but using it has caused compatibility issues with certain sites in166 # the past (see https://github.com/encode/httpx/issues/634), which is167 # why we don't call it here.168 # This is fine, though, because '.close()' schedules the actual closing of the169 # stream, meaning that at best it will happen during the next event loop170 # iteration, and at worst asyncio will take care of it on program exit.171 self.stream_writer.close()166 if sys.version_info >= (3, 7):167 await self.stream_writer.wait_closed()172173174class PoolSemaphore(BasePoolSemaphore):175 def __init__(self, max_value: int) -> None:
112 unmodified lines