Changeset b307cc1 in mod_gnutls


Ignore:
Timestamp:
Jan 7, 2020, 12:50:20 PM (3 years ago)
Author:
Fiona Klute <fiona.klute@…>
Branches:
asyncio, main, master, proxy-ticket
Children:
0cfe818
Parents:
a274959
git-author:
Fiona Klute <fiona.klute@…> (01/07/20 02:07:51)
git-committer:
Fiona Klute <fiona.klute@…> (01/07/20 12:50:20)
Message:

mgstest.http._stderr_writer: Always close input stream at EOS

Fixes "ResourceWarning?: unclosed file" after using an
HTTPSubprocessConnection.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/mgstest/http.py

    ra274959 rb307cc1  
    1717"""HTTP handling components for mod_gnutls tests."""
    1818
     19import contextlib
    1920import socket
    2021import subprocess
     
    122123    synchronization (via global interpreter lock).
    123124
     125    The incoming stream is closed after all lines have been read.
     126
    124127    """
    125     for line in stream:
    126         print(line.decode(), file=sys.stderr, end='', flush=True)
    127         if copy:
    128             print(line.decode(), file=copy, end='')
     128    with contextlib.closing(stream):
     129        for line in stream:
     130            print(line.decode(), file=sys.stderr, end='', flush=True)
     131            if copy:
     132                print(line.decode(), file=copy, end='')
Note: See TracChangeset for help on using the changeset viewer.