Skip to content

Commit

Permalink
no need to iterate once the task is found
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Jul 28, 2021
1 parent f979547 commit f8eee49
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion services/sidecar/src/simcore_service_sidecar/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ def cancel_task(task_name: str) -> None:
if task.get_name() == task_name:
logger.warning("canceling task %s....................", task)
task.cancel()
break


def cancel_task_by_fct_name(fct_name: str) -> None:
tasks = asyncio.all_tasks()
logger.debug("running tasks: %s", tasks)
for task in tasks:
if task.get_coro().__name__ == fct_name:
if task.get_coro().__name__ == fct_name: # type: ignore
logger.warning("canceling task %s....................", task)
task.cancel()
break

0 comments on commit f8eee49

Please sign in to comment.