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 bc4fda2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/2472.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use Popen context manager for periodic update process to prevent ResourceWarning due to unclosed files
2 changes: 1 addition & 1 deletion src/virtualenv/seed/wheels/periodic_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ 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
process = Popen(cmd, close_fds=True, **kwargs) # noqa: S603
logging.info(
"triggered periodic upgrade of %s%s (for python %s) via background process having PID %d",
distribution,
Expand Down

0 comments on commit bc4fda2

Please sign in to comment.