|
18 | 18 |
|
19 | 19 | from .tools import ToolboxTool
|
20 | 20 | from toolbox_core.sync_client import ToolboxSyncClient as ToolboxCoreSyncClient
|
| 21 | +from toolbox_core.sync_tool import ToolboxSyncTool |
21 | 22 |
|
22 | 23 |
|
23 | 24 |
|
@@ -90,15 +91,16 @@ async def aload_tool(
|
90 | 91 | bound_params=bound_params
|
91 | 92 | )
|
92 | 93 |
|
93 |
| - # If a loop has not been provided, attempt to run in current thread. |
94 | 94 | if not self.__core_sync_client._ToolboxSyncClient__loop:
|
95 |
| - return await coro |
96 |
| - |
97 |
| - # Otherwise, run in the background thread. |
98 |
| - core_sync_tool = await asyncio.wrap_future( |
99 |
| - asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop) |
100 |
| - ) |
101 |
| - |
| 95 | + # If a loop has not been provided, attempt to run in current thread. |
| 96 | + core_tool = await coro |
| 97 | + else: |
| 98 | + # Otherwise, run in the background thread. |
| 99 | + core_tool = await asyncio.wrap_future( |
| 100 | + asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop) |
| 101 | + ) |
| 102 | + |
| 103 | + core_sync_tool = ToolboxSyncTool(core_tool, self.__core_sync_client._ToolboxSyncClient__loop, self.__core_sync_client._ToolboxSyncClient__thread) |
102 | 104 | return ToolboxTool(core_sync_tool=core_sync_tool)
|
103 | 105 |
|
104 | 106 | async def aload_toolset(
|
@@ -165,15 +167,19 @@ async def aload_toolset(
|
165 | 167 | strict=strict
|
166 | 168 | )
|
167 | 169 |
|
168 |
| - # If a loop has not been provided, attempt to run in current thread. |
169 | 170 | if not self.__core_sync_client._ToolboxSyncClient__loop:
|
170 |
| - return await coro |
171 |
| - |
172 |
| - # Otherwise, run in the background thread. |
173 |
| - core_sync_tools = await asyncio.wrap_future( |
174 |
| - asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop) |
175 |
| - ) |
176 |
| - |
| 171 | + # If a loop has not been provided, attempt to run in current thread. |
| 172 | + core_tools = await coro |
| 173 | + else: |
| 174 | + # Otherwise, run in the background thread. |
| 175 | + core_tools = await asyncio.wrap_future( |
| 176 | + asyncio.run_coroutine_threadsafe(coro, self.__core_sync_client._ToolboxSyncClient__loop) |
| 177 | + ) |
| 178 | + |
| 179 | + core_sync_tools = [ |
| 180 | + ToolboxSyncTool(core_tool, self.__core_sync_client._ToolboxSyncClient__loop, self.__core_sync_client._ToolboxSyncClient__thread) |
| 181 | + for core_tool in core_tools |
| 182 | + ] |
177 | 183 | tools = []
|
178 | 184 | for core_sync_tool in core_sync_tools:
|
179 | 185 | tools.append(ToolboxTool(core_sync_tool=core_sync_tool))
|
|
0 commit comments