Skip to content

Commit c07ca53

Browse files
committed
fix(runtime): guard sync API when called from async context (closes #1085)
1 parent 1fb882e commit c07ca53

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/cocoindex/runtime.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def run(self, coro: Coroutine[Any, Any, T]) -> T:
4242
except RuntimeError:
4343
running_loop = None
4444

45-
loop = self.event_loop
45+
loop = self.event_loop
4646

4747
if running_loop is not None:
4848
if running_loop is loop:
@@ -69,4 +69,4 @@ def run(self, coro: Coroutine[Any, Any, T]) -> T:
6969
def to_async_call(call: Callable[..., Any]) -> Callable[..., Awaitable[Any]]:
7070
if inspect.iscoroutinefunction(call):
7171
return call
72-
return lambda *args, **kwargs: asyncio.to_thread(lambda: call(*args, **kwargs))
72+
return lambda *args, **kwargs: asyncio.to_thread(lambda: call(*args, **kwargs))

0 commit comments

Comments
 (0)