fix file descriptor leak in cmd.run()
we were leaking pipes.
This commit is contained in:
@@ -120,23 +120,23 @@ def run(
|
||||
tstart = datetime.datetime.now(tz=datetime.UTC)
|
||||
|
||||
# Start the subprocess
|
||||
process = subprocess.Popen(
|
||||
with subprocess.Popen(
|
||||
cmd,
|
||||
cwd=str(cwd),
|
||||
env=env,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
stdout_buf, stderr_buf = handle_output(process, log)
|
||||
) as process:
|
||||
stdout_buf, stderr_buf = handle_output(process, log)
|
||||
|
||||
if input:
|
||||
process.communicate(input)
|
||||
else:
|
||||
process.wait()
|
||||
tend = datetime.datetime.now(tz=datetime.UTC)
|
||||
if input:
|
||||
process.communicate(input)
|
||||
else:
|
||||
process.wait()
|
||||
tend = datetime.datetime.now(tz=datetime.UTC)
|
||||
|
||||
global TIME_TABLE
|
||||
TIME_TABLE.add(shlex.join(cmd), tend - tstart)
|
||||
global TIME_TABLE
|
||||
TIME_TABLE.add(shlex.join(cmd), tend - tstart)
|
||||
|
||||
# Wait for the subprocess to finish
|
||||
cmd_out = CmdOut(
|
||||
|
||||
Reference in New Issue
Block a user