25
25
26
26
27
27
class ToolboxSyncClient :
28
- __session : Optional [ClientSession ] = None
29
- __loop : Optional [asyncio .AbstractEventLoop ] = None
30
- __thread : Optional [Thread ] = None
31
28
"""
32
29
A synchronous client for interacting with a Toolbox service.
33
30
34
31
Provides methods to discover and load tools defined by a remote Toolbox
35
32
service endpoint, returning synchronous tool wrappers (`SyncToolboxTool`).
36
33
It manages an underlying asynchronous `ToolboxClient`.
37
34
"""
35
+ __session : Optional [ClientSession ] = None
36
+ __loop : Optional [asyncio .AbstractEventLoop ] = None
37
+ __thread : Optional [Thread ] = None
38
38
39
39
def __init__ (
40
40
self ,
@@ -56,7 +56,6 @@ def __init__(
56
56
ToolboxSyncClient .__loop = loop
57
57
58
58
async def __start_session () -> None :
59
-
60
59
# Use a default session if none is provided. This leverages connection
61
60
# pooling for better performance by reusing a single session throughout
62
61
# the application's lifetime.
@@ -105,7 +104,7 @@ def load_tool(
105
104
tool remotely.
106
105
107
106
Args:
108
- tool_name: The unique name or identifier of the tool to load.
107
+ tool_name: Name of the tool to load.
109
108
auth_token_getters: A mapping of authentication service names to
110
109
callables that return the corresponding authentication token.
111
110
bound_params: A mapping of parameter names to bind to specific values or
@@ -162,7 +161,7 @@ async def aload_tool(
162
161
bound_params : Mapping [str , Union [Callable [[], Any ], Any ]] = {},
163
162
) -> ToolboxSyncTool :
164
163
"""
165
- Synchronously loads a tool from the server.
164
+ Asynchronously loads a tool from the server.
166
165
167
166
Retrieves the schema for the specified tool and returns a callable,
168
167
synchronous object (`SyncToolboxTool`) that can be used to invoke the
@@ -193,7 +192,7 @@ async def aload_toolset(
193
192
bound_params : Mapping [str , Union [Callable [[], Any ], Any ]] = {},
194
193
) -> list [ToolboxSyncTool ]:
195
194
"""
196
- Synchronously fetches a toolset and loads all tools defined within it.
195
+ Asynchronously fetches a toolset and loads all tools defined within it.
197
196
198
197
Args:
199
198
toolset_name: Name of the toolset to load tools.
@@ -221,12 +220,9 @@ async def aload_toolset(
221
220
222
221
def close (self ):
223
222
"""
224
- Synchronously closes the underlying asynchronous client session if it
225
- was created internally by the client.
223
+ Synchronously closes the client session if it was created internally by the client.
226
224
"""
227
- # Create the coroutine for closing the async client
228
225
coro = self .__session .close ()
229
- # Run it synchronously
230
226
self .__run_as_sync (coro )
231
227
232
228
def __enter__ (self ):
0 commit comments