Wrap git invocations in `with`.

Review Request #14400 — Created April 14, 2025 and updated

Information

Review Board
master

Reviewers

Running with the latest Python, I was getting warnings about leaked file
descriptors, which were coming from git invocations inside the
GitClient, as it created BufferedReader instances for stdout/stderr.
This change wraps those subprocess invocations in with blocks, causing
things to get cleaned up appropriately.

Loaded some diffs and no longer saw warnings about leaked resources.

Summary ID
Wrap git invocations in `with`.
Running with the latest Python, I was getting warnings about leaked file descriptors, which were coming from `git` invocations inside the `GitClient`, as it created `BufferedReader` instances for stdout/stderr. This change wraps those subprocess invocations in `with` blocks, causing things to get cleaned up appropriately. Testing Done: Loaded some diffs and no longer saw warnings about leaked resources.
7351b24206b3a0d608bda2a4abef740730be3a2c
Description From Last Updated

Can you change '--git-dir=%s' to an f-string?

maubinmaubin
There are no open issues
maubin
  1. 
      
  2. reviewboard/scmtools/git.py (Diff revision 1)
     
     
    Show all issues

    Can you change '--git-dir=%s' to an f-string?

  3. 
      
david
Review request changed
Commits:
Summary ID
Wrap git invocations in `with`.
Running with the latest Python, I was getting warnings about leaked file descriptors, which were coming from `git` invocations inside the `GitClient`, as it created `BufferedReader` instances for stdout/stderr. This change wraps those subprocess invocations in `with` blocks, causing things to get cleaned up appropriately. Testing Done: Loaded some diffs and no longer saw warnings about leaked resources.
689b186907c59be8661fd538f166b17a50826553
Wrap git invocations in `with`.
Running with the latest Python, I was getting warnings about leaked file descriptors, which were coming from `git` invocations inside the `GitClient`, as it created `BufferedReader` instances for stdout/stderr. This change wraps those subprocess invocations in `with` blocks, causing things to get cleaned up appropriately. Testing Done: Loaded some diffs and no longer saw warnings about leaked resources.
7351b24206b3a0d608bda2a4abef740730be3a2c
Diff:

Revision 2 (+28 -22)

Show changes

reviewboard/scmtools/git.py

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
maubin
  1. Ship It!
  2. 
      
Loading...