Skip to content

Commit 50a1206

Browse files
committed
type notation for _waiters
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent b6b0f89 commit 50a1206

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import requests
55
import logging
66
from concurrent.futures import ThreadPoolExecutor
7-
from typing import Dict, Optional
7+
from typing import Dict, Optional, List
88
from databricks.sql.telemetry.models.event import (
99
TelemetryEvent,
1010
DriverSystemConfiguration,
@@ -37,8 +37,8 @@ class DebugLock:
3737
def __init__(self, name: str = "DebugLock"):
3838
self._lock = threading.Lock()
3939
self._name = name
40-
self._owner = None
41-
self._waiters = []
40+
self._owner: Optional[str] = None
41+
self._waiters: List[str] = []
4242
self._debug_logger = logging.getLogger(f"{__name__}.{name}")
4343
# Ensure debug logging is visible
4444
if not self._debug_logger.handlers:
@@ -55,27 +55,25 @@ def acquire(self, blocking=True, timeout=-1):
5555
thread_info = f"{current.name}-{current.ident}"
5656
if self._owner:
5757
self._debug_logger.warning(
58-
f":rotating_light: WAITING: {thread_info} waiting for lock held by {self._owner}"
58+
f": WAITING: {thread_info} waiting for lock held by {self._owner}"
5959
)
6060
self._waiters.append(thread_info)
6161
else:
6262
self._debug_logger.debug(
63-
f":large_green_circle: TRYING: {thread_info} attempting to acquire lock"
63+
f": TRYING: {thread_info} attempting to acquire lock"
6464
)
6565
# Try to acquire the lock
6666
acquired = self._lock.acquire(blocking, timeout)
6767
if acquired:
6868
self._owner = thread_info
69-
self._debug_logger.info(
70-
f":white_check_mark: ACQUIRED: {thread_info} got the lock"
71-
)
69+
self._debug_logger.info(f": ACQUIRED: {thread_info} got the lock")
7270
if self._waiters:
7371
self._debug_logger.info(
74-
f":clipboard: WAITERS: {len(self._waiters)} threads waiting: {self._waiters}"
72+
f": WAITERS: {len(self._waiters)} threads waiting: {self._waiters}"
7573
)
7674
else:
7775
self._debug_logger.error(
78-
f":x: FAILED: {thread_info} failed to acquire lock (timeout)"
76+
f": FAILED: {thread_info} failed to acquire lock (timeout)"
7977
)
8078
if thread_info in self._waiters:
8179
self._waiters.remove(thread_info)
@@ -86,19 +84,17 @@ def release(self):
8684
thread_info = f"{current.name}-{current.ident}"
8785
if self._owner != thread_info:
8886
self._debug_logger.error(
89-
f":rotating_light: ERROR: {thread_info} trying to release lock owned by {self._owner}"
87+
f": ERROR: {thread_info} trying to release lock owned by {self._owner}"
9088
)
9189
else:
92-
self._debug_logger.info(
93-
f":unlock: RELEASED: {thread_info} released the lock"
94-
)
90+
self._debug_logger.info(f": RELEASED: {thread_info} released the lock")
9591
self._owner = None
9692
# Remove from waiters if present
9793
if thread_info in self._waiters:
9894
self._waiters.remove(thread_info)
9995
if self._waiters:
10096
self._debug_logger.info(
101-
f":loudspeaker: NEXT: {len(self._waiters)} threads still waiting: {self._waiters}"
97+
f": NEXT: {len(self._waiters)} threads still waiting: {self._waiters}"
10298
)
10399
self._lock.release()
104100

0 commit comments

Comments
 (0)