We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4adf1c5 commit 2ae8a94Copy full SHA for 2ae8a94
singlestoredb/functions/ext/asgi.py
@@ -326,15 +326,16 @@ async def do_func(
326
rows: Sequence[Sequence[Any]],
327
) -> Tuple[Sequence[int], List[Tuple[Any, ...]]]:
328
'''Call function on given rows of data.'''
329
- out = []
+ tasks = []
330
async with timer('call_function'):
331
for row in rows:
332
cancel_on_event(cancel_event)
333
if is_async:
334
- out.append(await func(*row))
+ tasks.append(func(*row))
335
else:
336
- out.append(func(*row))
337
- return row_ids, list(zip(out))
+ tasks.append(asyncio.to_thread(func, *row))
+
338
+ return row_ids, list(zip(await asyncio.gather(*tasks)))
339
340
return do_func
341
0 commit comments