Skip to content

Commit

Permalink
another attempt at this
Browse files Browse the repository at this point in the history
  • Loading branch information
benc-db committed Jan 8, 2024
1 parent c698c8c commit a9c3f2b
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dbt/adapters/databricks/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,18 @@ def release(self) -> None:

conn._release()

# override
@classmethod
def close(cls, connection: Connection) -> Connection:
if not USE_LONG_SESSIONS:
return super().close(connection)

try:
return super().close(connection)
except Exception as e:
logger.warning(f"ignoring error when closing connection: {e}")
return connection

# override
def cleanup_all(self) -> None:
if not USE_LONG_SESSIONS:
Expand Down Expand Up @@ -1067,10 +1079,7 @@ def _cleanup_idle_connections(self) -> None:
for conn in thread_conns.values():
if conn.acquire_release_count == 0 and conn._idle_too_long():
logger.debug(f"closing idle connection: {conn._get_conn_info_str()}")
try:
self.close(conn)
except Exception as e:
logger.warning(f"ignoring error when closing connection: {e}")
self.close(conn)

conn.handle = LazyHandle(self._open2)

Expand Down

0 comments on commit a9c3f2b

Please sign in to comment.