Skip to content

Commit d90ac80

Browse files
committed
make close() async
1 parent 4452725 commit d90ac80

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,15 @@ def export_latency_log(self, latency_ms, sql_execution_event, sql_statement_id):
364364
)
365365

366366
def close(self):
367-
"""Flush remaining events and wait for them to complete before closing"""
368-
logger.debug("Closing TelemetryClient for connection %s", self._session_id_hex)
367+
"""Schedules the client to be closed in the background."""
368+
logger.debug(
369+
"Scheduling background closure for TelemetryClient of connection %s",
370+
self._session_id_hex,
371+
)
372+
self._executor.submit(self._close_and_wait)
373+
374+
def _close_and_wait(self):
375+
"""Flush remaining events and wait for them to complete before closing."""
369376
self._flush()
370377

371378
with self._lock:

0 commit comments

Comments
 (0)