1919
2020from hatchet_sdk import Context
2121from hatchet_sdk .client import Client , new_client_raw
22+ from hatchet_sdk .clients .dispatcher .action_listener import Action
2223from hatchet_sdk .contracts .workflows_pb2 import CreateWorkflowVersionOpts
2324from hatchet_sdk .loader import ClientConfig
2425from hatchet_sdk .logger import logger
2526from hatchet_sdk .utils .types import WorkflowValidator
2627from hatchet_sdk .utils .typing import is_basemodel_subclass
27- from hatchet_sdk .worker .action_listener_process import worker_action_listener_process
28- from hatchet_sdk .worker .runner .run_loop_manager import WorkerActionRunLoopManager
28+ from hatchet_sdk .worker .action_listener_process import (
29+ ActionEvent ,
30+ worker_action_listener_process ,
31+ )
32+ from hatchet_sdk .worker .runner .run_loop_manager import (
33+ STOP_LOOP_TYPE ,
34+ WorkerActionRunLoopManager ,
35+ )
2936from hatchet_sdk .workflow import WorkflowInterface
3037
3138T = TypeVar ("T" )
@@ -74,13 +81,13 @@ def __init__(
7481 self ._status : WorkerStatus
7582
7683 self .action_listener_process : BaseProcess
77- self .action_listener_health_check : asyncio .Task [Any ]
84+ self .action_listener_health_check : asyncio .Task [None ]
7885 self .action_runner : WorkerActionRunLoopManager
7986
8087 self .ctx = multiprocessing .get_context ("spawn" )
8188
82- self .action_queue : "Queue[Any ]" = self .ctx .Queue ()
83- self .event_queue : "Queue[Any ]" = self .ctx .Queue ()
89+ self .action_queue : "Queue[Action | STOP_LOOP_TYPE ]" = self .ctx .Queue ()
90+ self .event_queue : "Queue[ActionEvent ]" = self .ctx .Queue ()
8491
8592 self .loop : asyncio .AbstractEventLoop
8693
@@ -193,12 +200,10 @@ async def start_health_server(self) -> None:
193200
194201 logger .info (f"healthcheck server running on port { port } " )
195202
196- def start (
197- self , options : WorkerStartOptions = WorkerStartOptions ()
198- ) -> Future [asyncio .Task [Any ] | None ]:
203+ def start (self , options : WorkerStartOptions = WorkerStartOptions ()) -> None :
199204 self .owned_loop = self .setup_loop (options .loop )
200205
201- f = asyncio .run_coroutine_threadsafe (
206+ asyncio .run_coroutine_threadsafe (
202207 self .async_start (options , _from_start = True ), self .loop
203208 )
204209
@@ -209,14 +214,12 @@ def start(
209214 if self .handle_kill :
210215 sys .exit (0 )
211216
212- return f
213-
214217 ## Start methods
215218 async def async_start (
216219 self ,
217220 options : WorkerStartOptions = WorkerStartOptions (),
218221 _from_start : bool = False ,
219- ) -> Any | None :
222+ ) -> None :
220223 main_pid = os .getpid ()
221224 logger .info ("------------------------------------------" )
222225 logger .info ("STARTING HATCHET..." )
@@ -245,7 +248,7 @@ async def async_start(
245248 self ._check_listener_health ()
246249 )
247250
248- return await self .action_listener_health_check
251+ await self .action_listener_health_check
249252
250253 def _run_action_runner (self ) -> WorkerActionRunLoopManager :
251254 # Retrieve the shared queue
0 commit comments