1. Victor Stinner
  2. hachoir
Issue #33 new

open file handles never closed

damonlynch
created an issue

When metadata is extracted, e.g. self.parser = createParser(self.u_filename, self.filename) self.metadata = extractMetadata(self.parser) The file handle used by hachoir is never closed. Instructing python to forcefully delete the parser and metadata objects using the del statement does not even close the file handle. It is only closed when the process exits. This is most unfortunate if for instance the user wants to unmount a device and the process is still running.

Comments (8)

  1. Dustyn Gibson

    Victor Stinner So in order to make my project support both python3 and python2.7 using hachoir, I need to selectively import either hachoir or hachoir3? I wish it were not so =P.

    Still have to look into how the parser and metadata stuff works, to try and fix this issue.

  2. Kuang-che Wu

    I think switching between hachoir and hachoir3 is infeasible because the api is not compatible. For example, some module paths and names are changed due to refactoring.

    Maybe you can try 3to2 on hachoir3. I never tried it and don't know if it works.

  3. Dustyn Gibson

    Mark this solved.

    >>> 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>
    
  4. Log in to comment