Skip to content

Commit

Permalink
use Popen context manager for periodic update process (pypa#2472)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Aug 4, 2023
1 parent 119c63e commit 32da267
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/virtualenv/seed/wheels/periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,17 @@ def trigger_update(distribution, for_py_version, wheel, search_dirs, app_data, e
kwargs = {"stdout": pipe, "stderr": pipe}
if not debug and sys.platform == "win32":
kwargs["creationflags"] = CREATE_NO_WINDOW
process = Popen(cmd, **kwargs) # noqa: S603
logging.info(
"triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",
distribution,
"" if wheel is None else f"=={wheel.version}",
for_py_version,
process.pid,
)
if debug:
process.communicate() # on purpose not called to make it a background process

with Popen(cmd, **kwargs) as process: # noqa: S603
logging.info(
"triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",
distribution,
"" if wheel is None else f"=={wheel.version}",
for_py_version,
process.pid,
)
if debug:
process.communicate() # on purpose not called to make it a background process


def do_update(distribution, for_py_version, embed_filename, app_data, search_dirs, periodic): # noqa: PLR0913
Expand Down

0 comments on commit 32da267

Please sign in to comment.