Skip to content

Commit 4f66a84

Browse files
authored
feat(BA-1008): Make action processor work with async functions (#3999)
1 parent d72cd5c commit 4f66a84

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

changes/3999.feature.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make action processor work with async functions

src/ai/backend/manager/actions/processor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import asyncio
22
from datetime import datetime
3-
from typing import Callable, Generic, Optional
3+
from typing import Awaitable, Callable, Generic, Optional
44

55
from .action import (
66
BaseActionResultMeta,
@@ -13,11 +13,11 @@
1313

1414
class ActionProcessor(Generic[TAction, TActionResult]):
1515
_monitors: list[ActionMonitor]
16-
_func: Callable[[TAction], TActionResult]
16+
_func: Callable[[TAction], Awaitable[TActionResult]]
1717

1818
def __init__(
1919
self,
20-
func: Callable[[TAction], TActionResult],
20+
func: Callable[[TAction], Awaitable[TActionResult]],
2121
monitors: Optional[list[ActionMonitor]] = None,
2222
) -> None:
2323
self._func = func
@@ -27,7 +27,7 @@ async def _run(self, action: TAction) -> ProcessResult[TActionResult]:
2727
started_at = datetime.now()
2828
status: str
2929
try:
30-
result = self._func(action)
30+
result = await self._func(action)
3131
status = "success"
3232
description = "Success"
3333
except Exception as e:

0 commit comments

Comments
 (0)