Skip to content
Myr

Fix bug when using client without timeouts in Python 3.6 (#383)

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

authored by Florimond Manca · committed by Seth Michael Larson · parent 276ee73 · Browse files · 2 files+17 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+17 added−0 removed

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

2 files+17 added−0 removed

modified:httpx/concurrency/asyncio.py+6 added
79 unmodified lines
80 break81 except asyncio.TimeoutError:82 if should_raise:83 raise ReadTimeout() from None84 # FIX(py3.6): yield control back to the event loop to give it a chance85 # to cancel `.read(n)` before we retry.86 # This prevents concurrent `.read()` calls, which asyncio87 # doesn't seem to allow on 3.6.88 # See: https://github.com/encode/httpx/issues/38289 await asyncio.sleep(0)9091 return data9293 def write_no_block(self, data: bytes) -> None:
205 unmodified lines
modified:tests/test_timeouts.py+11 added
1import pytest23from httpx import (4 AsyncClient,5 Client,6 ConnectTimeout,7 PoolLimits,8 PoolTimeout,9 ReadTimeout,
37 unmodified lines
47 with pytest.raises(PoolTimeout):48 await client.get("http://localhost:8000/")4950 await response.read()515253def test_sync_infinite_timeout(server):54 """Regression test for a bug that occurred under Python 3.6.5556 See: https://github.com/encode/httpx/issues/38257 """58 no_timeout = TimeoutConfig()59 with Client(timeout=no_timeout) as client:60 client.get(server.url.copy_with(path="/slow_response/50"))