@@ -231,8 +231,7 @@ def create_task(
231231 with self .lock :
232232 self .tasks [task_id ] = task
233233
234- if parent_task_id and parent_task_id in self .tasks :
235- self .tasks [parent_task_id ].subtasks .append (task_id )
234+ if parent_task_id and parent_task_id in self .tasks : self .tasks [parent_task_id ].subtasks .append (task_id )
236235
237236 return task
238237
@@ -266,18 +265,17 @@ def execute_and_cleanup():
266265
267266 if run_async :
268267 future = self .executor .submit (execute_and_cleanup )
269- with self .lock :
268+ with self .lock :
270269 self .task_futures [task .id ] = future
271270 return task .id
272271 else : return execute_and_cleanup ()
273272
274273 def _handle_progress (self , task : AgentTask ):
275274 """Handle task progress updates"""
276- with self .lock :
275+ with self .lock :
277276 self .tasks [task .id ] = task
278277
279- if self .on_task_update :
280- self .on_task_update (task )
278+ if self .on_task_update : self .on_task_update (task )
281279
282280 def get_task (self , task_id : str ) -> Optional [AgentTask ]:
283281 """Get a task by ID"""
@@ -313,9 +311,8 @@ def cancel_task(self, task_id: str) -> bool:
313311 worker .cancel ()
314312 break
315313
316- # Cancel future if exists
317- if task_id in self .task_futures :
318- self .task_futures [task_id ].cancel ()
314+ # Cancel future if exists.
315+ if task_id in self .task_futures : self .task_futures [task_id ].cancel ()
319316
320317 return True
321318 return False
@@ -324,8 +321,7 @@ def cancel_all_tasks(self):
324321 """Cancel all running and queued tasks"""
325322 with self .lock :
326323 for task in self .tasks .values ():
327- if task .status in [AgentStatus .QUEUED , AgentStatus .RUNNING ]:
328- task .status = AgentStatus .CANCELLED
324+ if task .status in [AgentStatus .QUEUED , AgentStatus .RUNNING ]: task .status = AgentStatus .CANCELLED
329325
330326 for worker in self .workers .values ():
331327 worker .cancel ()
@@ -339,10 +335,8 @@ def wait_for_task(self, task_id: str, timeout: float = None) -> Optional[AgentTa
339335 future = self .task_futures .get (task_id )
340336
341337 if future :
342- try :
343- future .result (timeout = timeout )
344- except Exception :
345- pass
338+ try : future .result (timeout = timeout )
339+ except Exception : pass
346340
347341 return self .get_task (task_id )
348342
0 commit comments