Skip to content

Commit 4a414d8

Browse files
Fixed bug causing hang due to blocked task cancellation during asyncio
loop shutdown.
1 parent 2e23ab6 commit 4a414d8

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Thin Mode Changes
2929
:attr:`oracledb.DB_TYPE_TIMESTAMP`, :attr:`oracledb.DB_TYPE_TIMESTAMP_TZ`
3030
and :attr:`oracledb.DB_TYPE_TIMESTAMP_LTZ`.
3131
#) Fixed bug validating the database host during connection.
32+
#) Fixed bug causing hang due to blocked task cancellation during
33+
:ref:`asyncio <concurrentprogramming>` loop shutdown.
3234
#) Internal change: refactor encoding of Oracle data types.
3335
#) Internal change: small performance improvement sending bytes on the
3436
network transport.

src/oracledb/impl/thin/pool.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ cdef class AsyncThinPoolImpl(BaseThinPoolImpl):
720720
if num_to_create > 0 and self._open:
721721
try:
722722
conn_impl = await self._create_conn_impl()
723+
except asyncio.CancelledError:
724+
raise
723725
except:
724726
conn_impl = None
725727
async with self._condition:
@@ -732,6 +734,8 @@ cdef class AsyncThinPoolImpl(BaseThinPoolImpl):
732734
conn_impl = self._conn_impls_to_drop.pop()
733735
try:
734736
await conn_impl._protocol._close(conn_impl)
737+
except asyncio.CancelledError:
738+
raise
735739
except:
736740
pass
737741
continue

tests/test_2400_pool.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,3 +1062,10 @@ def test_2457(skip_if_drcp, test_env):
10621062
cursor.execute("select user from dual")
10631063
(user,) = cursor.fetchone()
10641064
assert user == test_env.main_user.upper()
1065+
1066+
1067+
def test_2458(test_env):
1068+
"2458 - connection to database with bad password"
1069+
pool = test_env.get_pool(password=test_env.main_password + "X")
1070+
with test_env.assert_raises_full_code("ORA-01017"):
1071+
pool.acquire()

tests/test_5500_pool_async.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,10 @@ async def test_5543(skip_if_drcp, test_env):
677677
await cursor.execute("select user from dual")
678678
(user,) = await cursor.fetchone()
679679
assert user == test_env.main_user.upper()
680+
681+
682+
async def test_5544(test_env):
683+
"5544 - connection to database with bad password"
684+
pool = test_env.get_pool_async(password=test_env.main_password + "X")
685+
with test_env.assert_raises_full_code("ORA-01017"):
686+
await pool.acquire()

0 commit comments

Comments
 (0)