Skip to content
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

Close file handles of Popen #4

Merged
merged 5 commits into from
Apr 30, 2021
Merged

Close file handles of Popen #4

merged 5 commits into from
Apr 30, 2021

Commits on Apr 30, 2021

  1. Wrap Popen with context manager

    Python started complaining that certain files have been left
    unclosed. To fix this, always make sure to close all file
    descriptors simply by wrapping the calls to Popen with a
    context manager as specified in the python documentation
    
    See: https://docs.python.org/3/library/subprocess.html#popen-constructor
    3j14 committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    9659cce View commit details
    Browse the repository at this point in the history
  2. Use "try: ... finally:" instead of context manager

    As support for python 2.7 should be maintained, a different
    approach has to be used. `Popen` does not implement a context
    manager (i.e. no __enter__ and __exit__ methods). The
    alternative is a `try: ... finally: ...` block. Note that I
    decided to put `Popen` inside this block. Thus, I had to set
    proc to be `None` as the `Popen` constructor itself could also
    raise an exception. Whether this approach is actually reasonable
    is debatable.
    3j14 committed Apr 30, 2021
    Configuration menu
    Copy the full SHA
    49d44e7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    806b389 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b948613 View commit details
    Browse the repository at this point in the history
  5. make fmt

    mbarkhau authored Apr 30, 2021
    Configuration menu
    Copy the full SHA
    291155d View commit details
    Browse the repository at this point in the history