Skip to content

Commit

Permalink
Fix #2444: Properly handle BaseException when re-raising
Browse files Browse the repository at this point in the history
  • Loading branch information
asvetlov committed Feb 9, 2018
1 parent 300afe5 commit 04e2a2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async def _request(self, method, url, *,
resp = req.send(conn)
try:
await resp.start(conn, read_until_eof)
except Exception:
except BaseException:
resp.close()
conn.close()
raise
Expand Down Expand Up @@ -425,7 +425,7 @@ async def _request(self, method, url, *,
)
return resp

except Exception as e:
except BaseException as e:
# cleanup timer
tm.close()
if handle:
Expand Down Expand Up @@ -611,7 +611,7 @@ async def _ws_connect(self, url, *,
writer = WebSocketWriter(
proto, transport, use_mask=True,
compress=compress, notakeover=notakeover)
except Exception:
except BaseException:
resp.close()
raise
else:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ async def read(self):
if self._content is None:
try:
self._content = await self.content.read()
except Exception:
except BaseException:
self.close()
raise

Expand Down
6 changes: 3 additions & 3 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ async def connect(self, req, traces=None):
if self._closed:
proto.close()
raise ClientConnectionError("Connector is closed.")
except Exception:
except BaseException:
# signal to waiter
if key in self._waiters:
for waiter in self._waiters[key]:
Expand Down Expand Up @@ -710,7 +710,7 @@ async def _resolve_host(self, host, port, traces=None):

self._cached_hosts.add(key, addrs)
self._throttle_dns_events[key].set()
except Exception as e:
except BaseException as e:
# any DNS exception, independently of the implementation
# is set for the waiters to raise the same exception.
self._throttle_dns_events[key].set(exc=e)
Expand Down Expand Up @@ -896,7 +896,7 @@ async def _create_proxy_connection(self, req, traces=None):
proxy_resp = proxy_req.send(conn)
try:
resp = await proxy_resp.start(conn, True)
except Exception:
except BaseException:
proxy_resp.close()
conn.close()
raise
Expand Down

0 comments on commit 04e2a2f

Please sign in to comment.