Skip to content

Commit

Permalink
Fix -p / --parallel handling of tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois committed Jan 3, 2025
1 parent 143ea00 commit 14e0fd0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 0.10.4

Fix `-p` / `--parallel` handling of tasks - no longer flatten them.

## 0.10.3

Gracefully handle keyboard interrupt and kill in-flight processes with logging.
Expand Down
2 changes: 1 addition & 1 deletion dev_cmd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 John Sirois.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

__version__ = "0.10.3"
__version__ = "0.10.4"
21 changes: 2 additions & 19 deletions dev_cmd/invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
from __future__ import annotations

import asyncio
import itertools
import os
import sys
from asyncio import CancelledError
from asyncio.subprocess import Process
from asyncio.tasks import Task as AsyncTask
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
from typing import Any, AsyncIterator, Container, Iterator
from typing import Any, AsyncIterator, Container

from dev_cmd import color
from dev_cmd.color import USE_COLOR
Expand All @@ -21,14 +20,6 @@
from dev_cmd.model import Command, ExitStyle, Group, Task


def _flatten(step: Command | Group | Task) -> Iterator[Command | Group]:
if isinstance(step, Task):
for step in step.steps.members:
yield from _flatten(step)
else:
yield step


def _step_prefix(step_name: str) -> str:
return color.cyan(f"dev-cmd {color.bold(step_name)}]")

Expand Down Expand Up @@ -134,15 +125,7 @@ async def invoke_parallel(
) -> None:
async with _guarded_stdin(), self._guarded_ctrl_c():
if error := await self._invoke_group(
"*",
Group(
members=tuple(
itertools.chain.from_iterable(_flatten(task) for task in self.steps)
)
),
*extra_args,
serial=False,
exit_style=exit_style,
"*", Group(members=self.steps), *extra_args, serial=False, exit_style=exit_style
):
await self._terminate_in_flight_processes()
raise error
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 14e0fd0

Please sign in to comment.