Skip to content

Commit 4bde3f3

Browse files
committed
APP-6379: Add public method init_for_thread() to prepare AtlanClient for use in multithreaded envs
1 parent 086d113 commit 4bde3f3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

pyatlan/client/atlan.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ class AtlanClient(BaseSettings):
190190
class Config:
191191
env_prefix = "atlan_"
192192

193+
@classmethod
194+
def init_for_thread(cls, client: AtlanClient):
195+
"""
196+
Prepares the given client for use in the current thread.
197+
198+
Sets the thread-local context and
199+
resets internal retry flags for multi-threaded environments.
200+
"""
201+
AtlanClient.set_current_client(client)
202+
client._401_tls.has_retried = False
203+
193204
@classmethod
194205
def set_current_client(cls, client: AtlanClient):
195206
"""
@@ -222,8 +233,7 @@ def __init__(self, **data):
222233
adapter = HTTPAdapter(max_retries=self.retry)
223234
session.mount(HTTPS_PREFIX, adapter)
224235
session.mount(HTTP_PREFIX, adapter)
225-
AtlanClient.set_current_client(self)
226-
self._401_tls.has_retried = False
236+
AtlanClient.init_for_thread(self)
227237

228238
@property
229239
def admin(self) -> AdminClient:

0 commit comments

Comments
 (0)