Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/agentex/lib/core/temporal/workers/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import uuid
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
from typing import Any
from typing import Any, overload

from aiohttp import web
from temporalio.client import Client
Expand Down Expand Up @@ -99,10 +99,28 @@ def __init__(
self.healthy = False
self.health_check_port = health_check_port

@overload
async def run(
self,
activities: list[Callable],
*,
workflow: type,
) -> None: ...

@overload
async def run(
self,
activities: list[Callable],
*,
workflows: list[type],
) -> None: ...

async def run(
self,
activities: list[Callable],
*,
workflow: type | None = None,
workflows: list[type] | None = None,
):
await self.start_health_check_server()
await self._register_agent()
Expand All @@ -119,7 +137,7 @@ async def run(
client=temporal_client,
task_queue=self.task_queue,
activity_executor=ThreadPoolExecutor(max_workers=self.max_workers),
workflows=[workflow],
workflows=[workflow] if workflows is None else workflows,
activities=activities,
workflow_runner=UnsandboxedWorkflowRunner(),
max_concurrent_activities=self.max_concurrent_activities,
Expand Down
Loading