Issue #56 duplicate

File locked for reading/writing after extracting video metadata

miigotu
created an issue

Hi, I have this piece of code in SickRage that creates a parser and extracts metadata from video files to determine height in order to help guess the video quality.

Shortly after the guessing of quality, we then move and rename the file, or on failure we copy and then os.unlink the original.

The issue we are having is that sometimes the file remains opened by hachoir, even though I explicitly del the parser and metadata before returning from the function.

Is there a way to make sure the file is closed?

Related issue on github https://github.com/SiCKRAGETV/sickrage-issues/issues/2534

Comments (7)

  1. miigotu reporter

    Kuang-che Wu yes, it is the same issue. I dont know how I didn't find that when searching.

    Curious if hachoir3 can also be used on python2.7 before I start patching this? If so I will switch code to hachoir3.

    We eventually want to support both python2.7 and python3, and if neither version can support both it complicates things for us.

  2. miigotu reporter

    Proof this works:

    >>> parser = createParser(u'/home/dusted/Videos/True Detective/Season 02/True Detective - S02E02 - Night Finds You.mp4')
    >>> parser.stream._input
    <open file u'/home/dusted/Videos/True Detective/Season 02/True Detective - S02E02 - Night Finds You.mp4', mode 'rb' at 0x7f57f6a711e0>
    >>> parser.stream._input.close()
    >>> parser.stream._input
    <closed file u'/home/dusted/Videos/True Detective/Season 02/True Detective - S02E02 - Night Finds You.mp4', mode 'rb' at 0x7f57f6a711e0>
    
  3. Log in to comment