File tree 2 files changed +8
-5
lines changed
2 files changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -317,7 +317,9 @@ def get_protocol_version(openSessionResp):
317
317
@property
318
318
def open (self ) -> bool :
319
319
"""Return whether the connection is open by checking if the session is open."""
320
- return self .session .is_open
320
+ # NOTE: we have to check for the existence of session in case the __del__ is called
321
+ # before the session is instantiated
322
+ return hasattr (self , "session" ) and self .session .open
321
323
322
324
def cursor (
323
325
self ,
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ def __init__(
29
29
30
30
This class handles all session-related behavior and communication with the backend.
31
31
"""
32
- self .is_open = False
32
+ self .open = False
33
33
self .host = server_hostname
34
34
self .port = kwargs .get ("_port" , 443 )
35
35
@@ -77,12 +77,13 @@ def __init__(
77
77
_use_arrow_native_complex_types = _use_arrow_native_complex_types ,
78
78
** kwargs ,
79
79
)
80
+
80
81
self ._open_session_resp = self .thrift_backend .open_session (
81
82
session_configuration , catalog , schema
82
83
)
83
84
self ._session_handle = self ._open_session_resp .sessionHandle
84
85
self .protocol_version = self .get_protocol_version (self ._open_session_resp )
85
- self .is_open = True
86
+ self .open = True
86
87
logger .info ("Successfully opened session " + str (self .get_session_id_hex ()))
87
88
88
89
@staticmethod
@@ -121,7 +122,7 @@ def get_session_id_hex(self):
121
122
def close (self ) -> None :
122
123
"""Close the underlying session."""
123
124
logger .info (f"Closing session { self .get_session_id_hex ()} " )
124
- if not self .is_open :
125
+ if not self .open :
125
126
logger .debug ("Session appears to have been closed already" )
126
127
return
127
128
@@ -142,4 +143,4 @@ def close(self) -> None:
142
143
except Exception as e :
143
144
logger .error (f"Attempt to close session raised a local exception: { e } " )
144
145
145
- self .is_open = False
146
+ self .open = False
You can’t perform that action at this time.
0 commit comments