Skip to content

Commit ff78b5f

Browse files
fix: separate session opening logic from instantiation
ensures correctness of self.session.open call in Connection Signed-off-by: varun-edachali-dbx <[email protected]>
1 parent 0b91183 commit ff78b5f

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/databricks/sql/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,7 @@ def get_protocol_version(openSessionResp):
344344
@property
345345
def open(self) -> bool:
346346
"""Return whether the connection is open by checking if the session is open."""
347-
# NOTE: we have to check for the existence of session in case the __del__ is called
348-
# before the session is instantiated
349-
return hasattr(self, "session") and self.session.open
347+
return self.session.is_open
350348

351349
def cursor(
352350
self,

src/databricks/sql/session.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131
3232
This class handles all session-related behavior and communication with the backend.
3333
"""
34-
self.open = False
34+
self.is_open = False
3535
self.host = server_hostname
3636
self.port = kwargs.get("_port", 443)
3737

@@ -144,4 +144,4 @@ def close(self) -> None:
144144
except Exception as e:
145145
logger.error(f"Attempt to close session raised a local exception: {e}")
146146

147-
self.open = False
147+
self.is_open = False

0 commit comments

Comments
 (0)