Skip to content

Commit e0f480e

Browse files
Fixed hang when using asyncio and a connection is unexpectedly closed by
the database.
1 parent 0ad6125 commit e0f480e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Thin Mode Changes
3535
(`issue 426 <https://github.com/oracle/python-oracledb/issues/426>`__).
3636
#) Fixed hang when attempting to use pipelining against a database that
3737
doesn't support the end of response flag.
38+
#) Fixed hang when using asyncio and a connection is unexpectedly closed by
39+
the database.
3840
#) Error ``DPY-6002: The distinguished name (DN) on the server certificate
3941
does not match the expected value: "{expected_dn}"`` now shows the expected
4042
value.

src/oracledb/impl/thin/protocol.pyx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#------------------------------------------------------------------------------
2-
# Copyright (c) 2020, 2024, Oracle and/or its affiliates.
2+
# Copyright (c) 2020, 2025, Oracle and/or its affiliates.
33
#
44
# This software is dual-licensed to you under the Universal Permissive License
55
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
@@ -761,7 +761,7 @@ cdef class BaseAsyncProtocol(BaseProtocol):
761761
except:
762762
if not self._in_connect \
763763
and self._write_buf._packet_sent \
764-
and self._read_buf._transport is not None:
764+
and self._transport is not None:
765765
self._send_marker(self._write_buf, TNS_MARKER_TYPE_BREAK)
766766
await self._reset()
767767
raise
@@ -888,6 +888,10 @@ cdef class BaseAsyncProtocol(BaseProtocol):
888888
"""
889889
if not self._in_connect:
890890
self._transport = None
891+
if self._read_buf._waiter is not None \
892+
and not self._read_buf._waiter.done():
893+
error = errors._create_err(errors.ERR_CONNECTION_CLOSED)
894+
self._read_buf._waiter.set_exception(error.exc_type(error))
891895

892896
def data_received(self, data):
893897
"""

0 commit comments

Comments
 (0)