Skip to content

List of arguments silently fails in subprocess.Popen whereas same list runs successfully in subprocess.run #133134

@aaronepinto

Description

@aaronepinto

Bug report

Bug description:

The following fails silently:

server_command = [
    "/opt/conda/envs/vila_env/bin/python",
    "-W",
    "ignore",
    "/tmp/app/VILA/custom_server.py",
    "--model-path",
    model_path,
    "--conv-mode",
    conv_mode,
    "--port",
    str(port),
]

self.vila_server_process = subprocess.Popen(
    server_command,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    shell=True,
    text=True,
)

Whereas the following two run as expected:

  1. Using Subprocess.run:
server_command = [
    "/opt/conda/envs/vila_env/bin/python",
    "-W",
    "ignore",
    "/tmp/app/VILA/custom_server.py",
    "--model-path",
    model_path,
    "--conv-mode",
    conv_mode,
    "--port",
    str(port),
]

self.vila_server_process = subprocess.run(
    server_command,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    shell=True,
    text=True,
)
  1. Using subprocess.Popen
server_command = f"/opt/conda/envs/vila_env/bin/python -W ignore /tmp/app/VILA/custom_server.py --model-path {model_path} --conv-mode {conv_mode} --port {port}"

self.vila_server_process = subprocess.Popen(
    server_command,
    stdout=subprocess.PIPE,
    stderr=subprocess.PIPE,
    shell=True,
    text=True,
)

The docstring for Popen specifies the following, hence pointing to this being unexpected:

     Arguments:
      args: A string, or a sequence of program arguments.

CPython versions tested on:

3.10

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions