Skip to content

Commit

Permalink
gitstat: no default timeout. Only use wait_for if timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Jan 21, 2024
1 parent 0cd68c7 commit 60f0063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/gitutils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,21 @@ def set_env(prompt: bool) -> dict:


async def subprocess_asyncio(
cmd: list[str], prompt: bool = False, timeout: float = TIMEOUT["remote"]
cmd: list[str], prompt: bool = False, timeout: float | None = None
) -> tuple[int, str, str]:
env = set_env(prompt)

proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
if timeout is None:
proc = await asyncio.create_subprocess_exec(
*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=env
),
timeout=timeout,
)
)
else:
proc = await asyncio.wait_for(
asyncio.create_subprocess_exec(
*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE, env=env
),
timeout=timeout,
)

stdout, stderr = await proc.communicate()

Expand Down
2 changes: 1 addition & 1 deletion src/gitutils/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def cli():
p = argparse.ArgumentParser(description="get status of many Git repos")
p.add_argument("path", help="path to look under", nargs="?", default="~/code")
p.add_argument("-v", "--verbose", action="store_true")
p.add_argument("-t", "--timeout", type=float, default=TIMEOUT["local"])
p.add_argument("-t", "--timeout", type=float)
p.add_argument("--serial", help="don't use asyncio parallel execution", action="store_true")
P = p.parse_args()

Expand Down

0 comments on commit 60f0063

Please sign in to comment.