File tree Expand file tree Collapse file tree 3 files changed +27
-19
lines changed
Expand file tree Collapse file tree 3 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,9 @@ Thin Mode Changes
5151#) Fixed bug when an Application Continuity replay context is returned during
5252 connection to the database
5353 (`issue 176 <https://github.com/oracle/python-oracledb/issues/176 >`__).
54+ #) Fixed bug when socket is not closed immediately upon failure to establish a
55+ connection to the database
56+ (`issue 211 <https://github.com/oracle/python-oracledb/issues/211 >`__).
5457
5558Thick Mode Changes
5659++++++++++++++++++
Original file line number Diff line number Diff line change @@ -324,14 +324,18 @@ cdef class ThinConnImpl(BaseConnImpl):
324324 def connect (self , ConnectParamsImpl params ):
325325 params._check_credentials()
326326 self ._connection_id = base64.b64encode(secrets.token_bytes(16 )).decode()
327- self ._connect_with_params(params)
328- self ._statement_cache = collections.OrderedDict()
329- self ._statement_cache_size = params.stmtcachesize
330- self ._statement_cache_lock = threading.Lock()
331- self ._dbobject_type_cache_num = create_new_dbobject_type_cache(self )
332- self ._cursors_to_close = array.array(' I' )
333- array.resize(self ._cursors_to_close, TNS_MAX_CURSORS_TO_CLOSE)
334- self .invoke_session_callback = True
327+ try :
328+ self ._connect_with_params(params)
329+ self ._statement_cache = collections.OrderedDict()
330+ self ._statement_cache_size = params.stmtcachesize
331+ self ._statement_cache_lock = threading.Lock()
332+ self ._dbobject_type_cache_num = create_new_dbobject_type_cache(self )
333+ self ._cursors_to_close = array.array(' I' )
334+ array.resize(self ._cursors_to_close, TNS_MAX_CURSORS_TO_CLOSE)
335+ self .invoke_session_callback = True
336+ except :
337+ self ._force_close()
338+ raise
335339
336340 def create_cursor_impl (self ):
337341 return ThinCursorImpl.__new__ (ThinCursorImpl, self )
Original file line number Diff line number Diff line change @@ -340,17 +340,18 @@ cdef class Protocol:
340340 Forces the connection closed. This is used when an unrecoverable error
341341 has taken place.
342342 """
343- sock = self ._socket
344- if DEBUG_PACKETS:
345- now = datetime.datetime.now()
346- print (now.isoformat(sep = " " , timespec = " milliseconds" ),
347- f" [socket: {sock.fileno()}]" , " force closing connection" )
348- print ()
349- self ._socket = None
350- self ._read_buf._socket = None
351- self ._write_buf._socket = None
352- sock.shutdown(socket.SHUT_RDWR)
353- sock.close()
343+ if self ._socket is not None :
344+ sock = self ._socket
345+ if DEBUG_PACKETS:
346+ now = datetime.datetime.now()
347+ print (now.isoformat(sep = " " , timespec = " milliseconds" ),
348+ f" [socket: {sock.fileno()}]" , " force closing connection" )
349+ print ()
350+ self ._socket = None
351+ self ._read_buf._socket = None
352+ self ._write_buf._socket = None
353+ sock.shutdown(socket.SHUT_RDWR)
354+ sock.close()
354355
355356 cdef int _process_message(self , Message message) except - 1 :
356357 try :
You can’t perform that action at this time.
0 commit comments