2424)
2525
2626
27- class RunnerFailedToStart (Exception ): ...
27+ class RunnerFailedToStart (Exception ):
28+ def __init__ (self , message : str ) -> None :
29+ self .message = message
2830
2931
3032async def notify_project_changed (project : domain .Project ) -> None :
@@ -181,6 +183,9 @@ async def update_runners(ws_context: context.WorkspaceContext) -> None:
181183 #
182184 # during initialization of new runners it also reads their configurations and
183185 # actions
186+ #
187+ # this function should handle all possible statuses of projects and they either
188+ # start of fail to start, only projects without finecode are ignored
184189 extension_runners = list (ws_context .ws_projects_extension_runners .values ())
185190 new_dirs , deleted_dirs = dirs_utils .find_changed_dirs (
186191 [* ws_context .ws_projects .keys ()],
@@ -198,20 +203,20 @@ async def update_runners(ws_context: context.WorkspaceContext) -> None:
198203 await stop_extension_runner (runner_to_delete )
199204 extension_runners .remove (runner_to_delete )
200205
201- new_runners_coros = [
202- start_extension_runner (runner_dir = new_dir , ws_context = ws_context )
203- for new_dir in new_dirs
204- if ws_context .ws_projects [new_dir ].status == domain .ProjectStatus .READY
205- ]
206206 new_runners_tasks : list [asyncio .Task ] = []
207207 try :
208208 async with asyncio .TaskGroup () as tg :
209- for coro in new_runners_coros :
210- runner_task = tg .create_task (coro )
211- new_runners_tasks .append (runner_task )
209+ for new_dir in new_dirs :
210+ project = ws_context .ws_projects [new_dir ]
211+ project_status = project .status
212+ if project_status == domain .ProjectStatus .READY :
213+ runner_task = tg .create_task (start_extension_runner (runner_dir = new_dir , ws_context = ws_context ))
214+ new_runners_tasks .append (runner_task )
215+ elif project_status != domain .ProjectStatus .NO_FINECODE :
216+ raise RunnerFailedToStart (f"Runner for project '{ project .name } ' failed to start, status: { project_status .name } " )
212217 except ExceptionGroup as eg :
213218 for exception in eg .exceptions :
214- if isinstance (exception , runner_client .BaseRunnerRequestException ):
219+ if isinstance (exception , runner_client .BaseRunnerRequestException ) or isinstance ( exception , RunnerFailedToStart ) :
215220 logger .error (exception .message )
216221 else :
217222 logger .exception (exception )
0 commit comments