MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / call_sync_from_async

Function call_sync_from_async

openhands/app_server/utils/async_utils.py:10–18  ·  view source on GitHub ↗

Shorthand for running a function in the default background thread pool executor and awaiting the result. The nature of synchronous code is that the future returned by this function is not cancellable

(fn: Callable, *args, **kwargs)

Source from the content-addressed store, hash-verified

8
9
10async def call_sync_from_async(fn: Callable, *args, **kwargs):
11 """Shorthand for running a function in the default background thread pool executor
12 and awaiting the result. The nature of synchronous code is that the future
13 returned by this function is not cancellable
14 """
15 loop = asyncio.get_event_loop()
16 coro = loop.run_in_executor(None, lambda: fn(*args, **kwargs))
17 result = await coro
18 return result
19
20
21def call_async_from_sync(

Callers 10

loadMethod · 0.90
storeMethod · 0.90
loadMethod · 0.90
storeMethod · 0.90
_get_models_responseMethod · 0.90
call_coro_in_bg_threadFunction · 0.85
run_in_loopFunction · 0.85

Calls

no outgoing calls

Tested by 2