Skip to content

Commit 27aa9d8

Browse files
committed
small fix
1 parent 351dd11 commit 27aa9d8

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/toolbox-core/src/toolbox_core/sync_client.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,27 @@ def __init__(
4848
"""
4949
# Running a loop in a background thread allows us to support async
5050
# methods from non-async environments.
51-
if ToolboxSyncClient.__loop is None:
51+
if self.__class__.__loop is None:
5252
loop = asyncio.new_event_loop()
5353
thread = Thread(target=loop.run_forever, daemon=True)
5454
thread.start()
55-
ToolboxSyncClient.__thread = thread
56-
ToolboxSyncClient.__loop = loop
55+
self.__class__.__thread = thread
56+
self.__class__.__loop = loop
5757

5858
async def __start_session() -> None:
5959
# Use a default session if none is provided. This leverages connection
6060
# pooling for better performance by reusing a single session throughout
6161
# the application's lifetime.
62-
if ToolboxSyncClient.__session is None:
63-
ToolboxSyncClient.__session = ClientSession()
64-
65-
coro = __start_session()
62+
if self.__class__.__session is None:
63+
self.__class__.__session = ClientSession()
6664

6765
asyncio.run_coroutine_threadsafe(
68-
__start_session(), ToolboxSyncClient.__loop
66+
__start_session(), self.__class__.__loop
6967
).result()
7068

71-
if not ToolboxSyncClient.__session:
69+
if not self.__class__.__session:
7270
raise ValueError("Session cannot be None.")
73-
self.__async_client = ToolboxClient(url, ToolboxSyncClient.__session)
71+
self.__async_client = ToolboxClient(url, self.__class__.__session)
7472

7573
def __run_as_sync(self, coro: Awaitable[T]) -> T:
7674
"""Run an async coroutine synchronously"""

0 commit comments

Comments
 (0)