Skip to content
Myr

Fix client.send() timeout new Request instance (#3116)

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

authored by Alex · committed by GitHub · parent df53451 · Browse files · 2 files+24 added−0 removed
This commit

State

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

Diff stats

2 files+24 added−0 removed

  • tests:+11 added−0 removed
  • other:+13 added−0 removed

2 files+24 added−0 removed

modified:httpx/_client.py+13 added
560 unmodified lines
561 return None562563 return request.stream564565 def _set_timeout(self, request: Request) -> None:566 if "timeout" not in request.extensions:567 timeout = (568 self.timeout569 if isinstance(self.timeout, UseClientDefault)570 else Timeout(self.timeout)571 )572 request.extensions = dict(**request.extensions, timeout=timeout.as_dict())573574575class Client(BaseClient):576 """577 An HTTP client, with connection pooling, HTTP/2, redirects, cookie persistence, etc.578
340 unmodified lines
919 if isinstance(follow_redirects, UseClientDefault)920 else follow_redirects921 )922923 self._set_timeout(request)924925 auth = self._build_request_auth(request, auth)926927 response = self._send_handling_auth(928 request,
739 unmodified lines
1668 if isinstance(follow_redirects, UseClientDefault)1669 else follow_redirects1670 )16711672 self._set_timeout(request)16731674 auth = self._build_request_auth(request, auth)16751676 response = await self._send_handling_auth(1677 request,
390 unmodified lines
modified:tests/test_timeouts.py+11 added
40 unmodified lines
41 async with httpx.AsyncClient(limits=limits, timeout=timeout) as client:42 with pytest.raises(httpx.PoolTimeout):43 async with client.stream("GET", server.url):44 await client.get(server.url)454647@pytest.mark.anyio48async def test_async_client_new_request_send_timeout(server):49 timeout = httpx.Timeout(1e-6)5051 async with httpx.AsyncClient(timeout=timeout) as client:52 with pytest.raises(httpx.TimeoutException):53 await client.send(54 httpx.Request("GET", server.url.copy_with(path="/slow_response"))55 )