Skip to content
Myr

Version 0.6.4 (#105)

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

* Read/Write timeout modes * Read/Write timeout modes * Tweaks for read/write timeout modes * Version 0.6.4 * Make slow_response slower for timeout test

authored by Tom Christie · committed by GitHub · parent f4f05e3 · Browse files · 3 files+11 added−7 removed
This commit

State

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

Diff stats

3 files+11 added−7 removed

  • tests:+1 added−1 removed
  • other:+10 added−6 removed

3 files+11 added−7 removed

modified:http3/__init__.py+1 added-1 removed
47 unmodified lines
48 Response,49)50from .status_codes import StatusCode, codes5152__version__ = "0.6.3"52__version__ = "0.6.4"
modified:http3/concurrency.py+9 added-5 removed
93 unmodified lines
94 if timeout is None:95 timeout = self.timeout9697 while True:98 # Check our flag at the first possible moment, and use a fine99 # grained retry loop if we're not yet in read-timeout mode.100 should_raise = flag is None or flag.raise_on_read_timeout101 read_timeout = timeout.read_timeout if should_raise else 0.01102 try:100 data = await asyncio.wait_for(101 self.stream_reader.read(n), timeout.read_timeout102 )103 data = await asyncio.wait_for(self.stream_reader.read(n), read_timeout)104 break105 except asyncio.TimeoutError:106 if should_raise:106 raise ReadTimeout()107 raise ReadTimeout() from None108109 return data110111
21 unmodified lines
133 self.stream_writer.drain(), timeout.write_timeout134 )135 break136 except asyncio.TimeoutError:137 # We check our flag at the possible moment, in order to138 # allow us to suppress write timeouts, if we've since139 # switched over to read-timeout mode.140 should_raise = flag is None or flag.raise_on_write_timeout141 if should_raise:138 raise WriteTimeout()142 raise WriteTimeout() from None143144 async def close(self) -> None:145 self.stream_writer.close()146
125 unmodified lines
modified:tests/conftest.py+1 added-1 removed
28 unmodified lines
29 await send({"type": "http.response.body", "body": b"Hello, world!"})303132async def slow_response(scope, receive, send):33 await asyncio.sleep(0.01)33 await asyncio.sleep(0.1)34 await send(35 {36 "type": "http.response.start",37 "status": 200,
74 unmodified lines