Skip to content

Commit e5789af

Browse files
committed
disambiguate asyncio.TimeoutError from OSError
in 3.11 asyncio.TimeoutError became an OSError
1 parent 37fa089 commit e5789af

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

aiohttp/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,8 @@ async def _request(
531531
raise
532532
except ClientError:
533533
raise
534+
except asyncio.TimeoutError:
535+
raise
534536
except OSError as exc:
535537
raise ClientOSError(*exc.args) from exc
536538

aiohttp/client_reqrep.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,8 @@ async def write_bytes(
536536
await writer.write(chunk) # type: ignore[arg-type]
537537

538538
await writer.write_eof()
539+
except asyncio.TimeoutError:
540+
raise
539541
except OSError as exc:
540542
new_exc = ClientOSError(
541543
exc.errno, "Can not write request body for %s" % self.url

aiohttp/connector.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ async def _wrap_create_connection(
969969
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
970970
except ssl_errors as exc:
971971
raise ClientConnectorSSLError(req.connection_key, exc) from exc
972+
except asyncio.TimeoutError:
973+
raise
972974
except OSError as exc:
973975
raise client_error(req.connection_key, exc) from exc
974976

@@ -1048,6 +1050,8 @@ async def _start_tls_connection(
10481050
raise ClientConnectorCertificateError(req.connection_key, exc) from exc
10491051
except ssl_errors as exc:
10501052
raise ClientConnectorSSLError(req.connection_key, exc) from exc
1053+
except asyncio.TimeoutError:
1054+
raise
10511055
except OSError as exc:
10521056
raise client_error(req.connection_key, exc) from exc
10531057
except TypeError as type_err:
@@ -1099,6 +1103,8 @@ def drop_exception(fut: "asyncio.Future[List[Dict[str, Any]]]") -> None:
10991103

11001104
host_resolved.add_done_callback(drop_exception)
11011105
raise
1106+
except asyncio.TimeoutError:
1107+
raise
11021108
except OSError as exc:
11031109
# in case of proxy it is not ClientProxyConnectionError
11041110
# it is problem of resolving proxy ip itself
@@ -1292,6 +1298,8 @@ async def _create_connection(
12921298
_, proto = await self._loop.create_unix_connection(
12931299
self._factory, self._path
12941300
)
1301+
except asyncio.TimeoutError:
1302+
raise
12951303
except OSError as exc:
12961304
raise UnixClientConnectorError(self.path, req.connection_key, exc) from exc
12971305

@@ -1357,6 +1365,8 @@ async def _create_connection(
13571365
await asyncio.sleep(0)
13581366
# other option is to manually set transport like
13591367
# `proto.transport = trans`
1368+
except asyncio.TimeoutError:
1369+
raise
13601370
except OSError as exc:
13611371
raise ClientConnectorError(req.connection_key, exc) from exc
13621372

0 commit comments

Comments
 (0)