Skip to content

Commit

Permalink
feat(subp): Measure subprocess command time
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Nov 14, 2023
1 parent 745fbf6 commit a3f7084
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cloudinit/subp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import logging
import os
import subprocess
import time
from errno import ENOEXEC
from io import TextIOWrapper
from typing import List, Union
Expand Down Expand Up @@ -277,6 +278,7 @@ def subp(
x if isinstance(x, bytes) else x.encode("utf-8") for x in args
]
try:
before = time.time()
sp = subprocess.Popen(
bytes_args,
stdout=stdout,
Expand All @@ -287,6 +289,7 @@ def subp(
cwd=cwd,
)
(out, err) = sp.communicate(data)
LOG.debug("command %s took %.3ss to run", args, time.time() - before)
except OSError as e:
if status_cb:
status_cb("ERROR: End run command: invalid command provided\n")
Expand Down

0 comments on commit a3f7084

Please sign in to comment.