Skip to content

Commit 9da0462

Browse files
authored
Merge branch 'main' into add_py312_compat
2 parents f9d9eca + 77fed9b commit 9da0462

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

ads/telemetry/client.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import traceback
99
import urllib.parse
1010
from typing import Optional
11+
import concurrent.futures
1112

1213
import oci
1314

@@ -16,7 +17,8 @@
1617
from .base import TelemetryBase
1718

1819
logger = logging.getLogger(__name__)
19-
20+
THREAD_POOL_SIZE = 16
21+
thread_pool = concurrent.futures.ThreadPoolExecutor(max_workers=THREAD_POOL_SIZE)
2022

2123
class TelemetryClient(TelemetryBase):
2224
"""Represents a telemetry python client providing functions to record an event.
@@ -102,7 +104,7 @@ def record_event(
102104

103105
def record_event_async(
104106
self, category: str = None, action: str = None, detail: str = None, **kwargs
105-
):
107+
)-> None:
106108
"""Send a head request to generate an event record.
107109
108110
Parameters
@@ -117,9 +119,4 @@ def record_event_async(
117119
Thread
118120
A started thread to send a head request to generate an event record.
119121
"""
120-
thread = threading.Thread(
121-
target=self.record_event, args=(category, action, detail), kwargs=kwargs
122-
)
123-
thread.daemon = True
124-
thread.start()
125-
return thread
122+
thread_pool.submit(self.record_event, args=(category, action, detail), kwargs=kwargs)

0 commit comments

Comments
 (0)