File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def __init__(
5151 self ._usecase = usecase
5252
5353 # We only retry connection problems, as we cannot rewind our compression stream.
54- self ._retries = retries or urllib3 .Retry (connect = 3 , redirect = 5 )
54+ self ._retries = retries or urllib3 .Retry (connect = 3 , redirect = 5 , read = 0 )
5555 # The read timeout is defined to be "between consecutive read operations",
5656 # which should mean one chunk of the response, with a large response being
5757 # split into multiple chunks.
Original file line number Diff line number Diff line change @@ -105,3 +105,17 @@ def test_full_cycle(server_url: str) -> None:
105105
106106 with pytest .raises (ClientError , check = lambda e : e .status == 404 ):
107107 client .get (object_key )
108+
109+
110+ def test_connect_timeout () -> None :
111+ # this server accepts the connection
112+ # (even though the backlog is 0 and we never call `accept`),
113+ # but will never reply with anything, thus causing a read timeout
114+ s = socket .create_server (("127.0.0.1" , 0 ), backlog = 0 )
115+ addr = s .getsockname ()
116+ url = f"http://127.0.0.1:{ addr [1 ]} "
117+
118+ timeout = urllib3 .Timeout (connect = 0.05 , read = 0.05 ) # 50ms
119+ client = ClientBuilder (url , "test-usecase" , timeout = timeout ).for_organization (12345 )
120+ with pytest .raises (urllib3 .exceptions .MaxRetryError ):
121+ client .put (b"foo" )
You can’t perform that action at this time.
0 commit comments