Skip to content

Commit 123d9f1

Browse files
committed
locks are useless anyways
1 parent 791ff1a commit 123d9f1

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,9 @@ def _export_event(self, event):
183183

184184
def _flush(self):
185185
"""Flush the current batch of events to the server"""
186-
# with self._lock:
187-
events_to_flush = self._events_batch.copy()
188-
self._events_batch = []
186+
with self._lock:
187+
events_to_flush = self._events_batch.copy()
188+
self._events_batch = []
189189

190190
if events_to_flush:
191191
logger.debug("Flushing %s telemetry events to server", len(events_to_flush))
@@ -397,20 +397,20 @@ def get_telemetry_client(session_id_hex):
397397
def close_telemetry_client(session_id_hex):
398398
"""Remove the telemetry client for a specific connection"""
399399
global _initialized, _executor
400-
with _lock:
401-
if session_id_hex in _clients:
402-
logger.debug("Removing telemetry client for connection %s", session_id_hex)
403-
telemetry_client = _clients.pop(session_id_hex, None)
404-
telemetry_client.close()
405400

406-
# Shutdown executor if no more clients
407-
try:
408-
if not _clients and _executor:
409-
logger.debug(
410-
"No more telemetry clients, shutting down thread pool executor"
411-
)
412-
_executor.shutdown(wait=True)
413-
_executor = None
414-
_initialized = False
415-
except Exception as e:
416-
logger.debug("Failed to shutdown thread pool executor: %s", e)
401+
if session_id_hex in _clients:
402+
logger.debug("Removing telemetry client for connection %s", session_id_hex)
403+
telemetry_client = _clients.pop(session_id_hex, None)
404+
telemetry_client.close()
405+
406+
# Shutdown executor if no more clients
407+
try:
408+
if not _clients and _executor:
409+
logger.debug(
410+
"No more telemetry clients, shutting down thread pool executor"
411+
)
412+
_executor.shutdown(wait=True)
413+
_executor = None
414+
_initialized = False
415+
except Exception as e:
416+
logger.debug("Failed to shutdown thread pool executor: %s", e)

0 commit comments

Comments
 (0)