[New-bugs-announce] [issue41619] Subprocesses created with DETACHED_PROCESS can pop up a console window

Paul Moore report at bugs.python.org
Sun Aug 23 08:54:10 EDT 2020


New submission from Paul Moore <p.f.moore at gmail.com>:

The following code pops up an extra console window when run on Windows 10, Python 3.8:

    from subprocess import DETACHED_PROCESS, Popen
    p = Popen(["py", "-c", "from time import sleep; sleep(5)"], creationflags=DETACHED_PROCESS)

Adding CREATE_NO_WINDOW doesn't help, nor does adding a STARTUPINFO with SW_HIDE.

The problem occurs whether the Python interpreter is started via the py.exe wrapper or the actual python.exe. However, changing the process being run from "py" to sys.executable makes the problem go away. I've seen similar issues when using sys.executable, but the script is being called from a virtualenv.

I can't find any set of options for Popen that reliably avoids showing a console window when invoked like this.

----------
components: Windows
messages: 375811
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Subprocesses created with DETACHED_PROCESS can pop up a console window
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41619>
_______________________________________


More information about the New-bugs-announce mailing list