The session attribute is set on the Connection here:
.
If connecting fails (e.g. due to invalid host or credentials) then no session attribute will be set, but __del__ will still be called when the not-fully-initialized Connection instance is destroyed. This causes warnings to be printed to stderr.
A simple fix would be to check if session is set in open or doing the same thing in __del__ only, to keep the semantics of open intact.
The
sessionattribute is set on theConnectionhere:databricks-sql-python/src/databricks/sql/client.py
Line 296 in 9fe7356
If connecting fails (e.g. due to invalid host or credentials) then no
sessionattribute will be set, but__del__will still be called when the not-fully-initializedConnectioninstance is destroyed. This causes warnings to be printed to stderr.A simple fix would be to check if
sessionis set inopenor doing the same thing in__del__only, to keep the semantics ofopenintact.