@@ -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 }
@@ -292,7 +298,13 @@ def __enter__(self) -> "Connection":
292298 return self
293299
294300 def __exit__ (self , exc_type , exc_value , traceback ):
295- self .close ()
301+ try :
302+ self .close ()
303+ except BaseException as e :
304+ logger .warning (f"Exception during connection close in __exit__: { e } " )
305+ if exc_type is None :
306+ raise
307+ return False
296308
297309 def __del__ (self ):
298310 if self .open :
@@ -415,7 +427,14 @@ def __enter__(self) -> "Cursor":
415427 return self
416428
417429 def __exit__ (self , exc_type , exc_value , traceback ):
418- self .close ()
430+ try :
431+ logger .debug ("Cursor context manager exiting, calling close()" )
432+ self .close ()
433+ except BaseException as e :
434+ logger .warning (f"Exception during cursor close in __exit__: { e } " )
435+ if exc_type is None :
436+ raise
437+ return False
419438
420439 def __iter__ (self ):
421440 if self .active_result_set :
@@ -746,6 +765,9 @@ def execute(
746765
747766 :returns self
748767 """
768+ logger .debug (
769+ "Cursor.execute(operation=%s, parameters=%s)" , operation , parameters
770+ )
749771
750772 param_approach = self ._determine_parameter_approach (parameters )
751773 if param_approach == ParameterApproach .NONE :
0 commit comments