Skip to content

Commit f62de29

Browse files
check if async func and await
1 parent 64b4836 commit f62de29

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

singlestoredb/functions/ext/asgi.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,12 @@ async def do_func(
319319
row_ids = array_cls(row_ids)
320320

321321
# Call the function with `cols` as the function parameters
322-
if cols and cols[0]:
323-
out = func(*[x if m else x[0] for x, m in zip(cols, masks)])
322+
is_async = inspect.iscoroutinefunction(func) or inspect.iscoroutinefunction(getattr(func, "__wrapped__", None))
323+
if is_async:
324+
out = await func(*[x if m else x[0] for x, m in zip(cols, masks)])
324325
else:
325-
out = func()
326-
326+
out = await asyncio.to_thread(func, *[x if m else x[0] for x, m in zip(cols, masks)])
327+
327328
# Single masked value
328329
if isinstance(out, Masked):
329330
return row_ids, [tuple(out)]

0 commit comments

Comments
 (0)