diff --git a/src/zrb/task/cmd_task.py b/src/zrb/task/cmd_task.py index 375988bb..8a0c2b84 100644 --- a/src/zrb/task/cmd_task.py +++ b/src/zrb/task/cmd_task.py @@ -260,8 +260,14 @@ def _on_kill(self, signum: Any, frame: Any): self.print_out_dark(f'Getting signal {signum}') for pid in self._pids: self._kill_by_pid(pid) - self.print_out_dark(f'Exiting with signal {signum}') + tasks = asyncio.all_tasks() + for task in tasks: + try: + task.cancel() + except Exception as e: + self.print_err(e) time.sleep(0.3) + self.print_out_dark(f'Exiting with signal {signum}') sys.exit(signum) def _on_exit(self): diff --git a/test/task/test_task.py b/test/task/test_task.py index c5fda776..abaf1a55 100644 --- a/test/task/test_task.py +++ b/test/task/test_task.py @@ -271,7 +271,7 @@ def _run(*args, **kwargs) -> str: del os.environ['COLOR'] -def test_task_redeclared_env(): +def test_task_duplicate_env(): ''' When env exist, it should override env_file, If two env has the same name, the later should override the first one