diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-06-18 17:42:53 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-06-18 23:14:20 -0400 |
commit | 81cc6829f4538649c3c848767bcab55039767d85 (patch) | |
tree | a0cf95905dd6ea017846275ec034210986a14aca /lib/sqlalchemy/util/_concurrency_py3k.py | |
parent | 99e556b9d112fc6b3a301915dd59d739fdaadc36 (diff) | |
download | sqlalchemy-81cc6829f4538649c3c848767bcab55039767d85.tar.gz |
ensure greenlet_spawn propagates BaseException
Fixed bug in asyncio implementation where the greenlet adaptation system
failed to propagate ``BaseException`` subclasses, most notably including
``asyncio.CancelledError``, to the exception handling logic used by the
engine to invalidate and clean up the connection, thus preventing
connections from being correctly disposed when a task was cancelled.
Fixes: #6652
Change-Id: Id3809e6c9e7bced46a7a3b5a0d1906c4168dc4fc
Diffstat (limited to 'lib/sqlalchemy/util/_concurrency_py3k.py')
-rw-r--r-- | lib/sqlalchemy/util/_concurrency_py3k.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/sqlalchemy/util/_concurrency_py3k.py b/lib/sqlalchemy/util/_concurrency_py3k.py index 88294557d..c6d1fa5d3 100644 --- a/lib/sqlalchemy/util/_concurrency_py3k.py +++ b/lib/sqlalchemy/util/_concurrency_py3k.py @@ -25,6 +25,8 @@ else: def is_exit_exception(e): + # note asyncio.CancelledError is already BaseException + # so was an exit exception in any case return not isinstance(e, Exception) or isinstance( e, (asyncio.TimeoutError, asyncio.CancelledError) ) @@ -118,7 +120,7 @@ async def greenlet_spawn( # wait for a coroutine from await_ and then return its # result back to it. value = await result - except Exception: + except BaseException: # this allows an exception to be raised within # the moderated greenlet so that it can continue # its expected flow. |