File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616from databricks .sql import *
1717from databricks .sql .exc import (
1818 OperationalError ,
19+ RequestError ,
1920 SessionAlreadyClosedError ,
2021 CursorAlreadyClosedError ,
2122 InterfaceError ,
@@ -1770,6 +1771,14 @@ def close(self) -> None:
17701771 # attempt a network call on an already-torn-down session.
17711772 try :
17721773 self .backend .close_command (self .active_command_id )
1774+ except RequestError as e :
1775+ if isinstance (e .args [1 ], CursorAlreadyClosedError ):
1776+ # Already-closed handle (e.g. a prior cancel() or concurrent
1777+ # session teardown) is an expected, benign case — mirror
1778+ # ResultSet.close and log at info, not warning.
1779+ logger .info ("Operation was canceled by a prior request" )
1780+ else :
1781+ logger .warning ("close_command on cursor close failed: %s" , e )
17731782 except Exception as exc :
17741783 logger .warning ("close_command on cursor close failed: %s" , exc )
17751784 self .active_command_id = None
You can’t perform that action at this time.
0 commit comments