imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

_io.read_frames causes "ResourceWarning: unclosed file" #61

Closed dennisvang closed 2 years ago

dennisvang commented 2 years ago

Description

read_frames.close() leads to a ResourceWarning: unclosed file, e.g. when running unittest tests.

This implies that the standard streams are not being closed properly, similar to https://github.com/imageio/imageio/issues/697:

stderr is opened here but not explicitly closed (here?).

How to reproduce

Add the following test to test_io.py and run (tested on Windows 10, Python 3.8):

def test_read_frames_resource_warning():
    with pytest.warns(None) as warnings:
        gen = imageio_ffmpeg.read_frames(test_file1)
        next(gen)
        gen.close()
    # there should not be any warnings, but show warning messages if there are
    assert not [w.message for w in warnings]
almarklein commented 2 years ago

Closed by #62