Skip to content

Commit 62ef0b5

Browse files
committed
asyncio.CancelledError does not subclass Exception
CancelledError does not subclass Exception anymore since 3.8 (and correctly so), but this broke control flow at a couple location and was annoying to debug.
1 parent b04a724 commit 62ef0b5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

asyncio_pool/base_pool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async def _wrap(self, coro, future, cb=None, ctx=None):
106106
res, exc, tb = None, None, None
107107
try:
108108
res = await coro
109-
except Exception as _exc:
109+
except BaseException as _exc:
110110
exc = _exc
111111
tb = traceback.format_exc()
112112
finally:
@@ -140,7 +140,7 @@ async def _spawn(self, future, coro, cb=None, ctx=None):
140140
acq_error = False
141141
try:
142142
await self.semaphore.acquire()
143-
except Exception as e:
143+
except BaseException as e:
144144
acq_error = True
145145
if not future.done():
146146
future.set_exception(e)

asyncio_pool/results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def result_noraise(future, flat=True):
1414
try:
1515
res = future.result()
1616
return res if flat else (res, None)
17-
except Exception as exc:
17+
except BaseException as exc:
1818
return exc if flat else (None, exc)
1919

2020

examples/_usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def cb(res, err, ctx): # callback
110110
# results.append(getres.flat(fut))
111111
try:
112112
results.append(fut.result())
113-
except Exception as e:
113+
except BaseException as e:
114114
results.append(e)
115115

116116
# First error happens for n == 0 in wrk, exception of it is passed to

0 commit comments

Comments
 (0)