Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
aaronepinto opened this issue Apr 29, 2025 · 1 comment
Labels
type-bug An unexpected behavior, bug, or error

Comments

@aaronepinto
Copy link

aaronepinto commented Apr 29, 2025

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

@aaronepinto aaronepinto added the type-bug An unexpected behavior, bug, or error label Apr 29, 2025
@graingert
Copy link
Contributor

graingert commented Apr 29, 2025

This is the CPython issue tracker and Python 3.10 is in security fixes only level of support.

Please try your code on a bugfix-supported version of python eg 3.13 or 3.12

Additionally, please open a help thread on https://discuss.python.org/c/help/7 please make your example snippets runnable by including definitions for self, model_path etc and all imports, please also include the full output and what you mean by fails silently.

subprocess.run directly passes it's positional arguments to subprocess.Popen so I don't think that's related. Perhaps you're missing a call to the communicate method?

@graingert graingert closed this as not planned Won't fix, can't repro, duplicate, stale Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants