@@ -217,6 +217,12 @@ def read(self) -> Optional[OAuthToken]:
217217 # use_cloud_fetch
218218 # Enable use of cloud fetch to extract large query results in parallel via cloud storage
219219
220+ logger .debug (
221+ "Connection.__init__(server_hostname=%s, http_path=%s)" ,
222+ server_hostname ,
223+ http_path ,
224+ )
225+
220226 if access_token :
221227 access_token_kv = {"access_token" : access_token }
222228 kwargs = {** kwargs , ** access_token_kv }
@@ -291,7 +297,13 @@ def __enter__(self) -> "Connection":
291297 return self
292298
293299 def __exit__ (self , exc_type , exc_value , traceback ):
294- self .close ()
300+ try :
301+ self .close ()
302+ except BaseException as e :
303+ logger .warning (f"Exception during connection close in __exit__: { e } " )
304+ if exc_type is None :
305+ raise
306+ return False
295307
296308 def __del__ (self ):
297309 if self .open :
@@ -414,7 +426,14 @@ def __enter__(self) -> "Cursor":
414426 return self
415427
416428 def __exit__ (self , exc_type , exc_value , traceback ):
417- self .close ()
429+ try :
430+ logger .debug ("Cursor context manager exiting, calling close()" )
431+ self .close ()
432+ except BaseException as e :
433+ logger .warning (f"Exception during cursor close in __exit__: { e } " )
434+ if exc_type is None :
435+ raise
436+ return False
418437
419438 def __iter__ (self ):
420439 if self .active_result_set :
@@ -745,6 +764,9 @@ def execute(
745764
746765 :returns self
747766 """
767+ logger .debug (
768+ "Cursor.execute(operation=%s, parameters=%s)" , operation , parameters
769+ )
748770
749771 param_approach = self ._determine_parameter_approach (parameters )
750772 if param_approach == ParameterApproach .NONE :
0 commit comments