Skip to content

PyExiftool hangs if exiftool redirects to stderr #105

@Rondineli

Description

@Rondineli

Because exiftool tries to reads from stdout this line with a block and no timeout the process hangs waiting for a stdout response. If exiftool fails, like adding a char that exiftool does not expect, like:

import exiftool

pic = b"/tmp/tmpv3xu9816"
# for some reason, exiftool does not like `-` and or ` ` at end of tags
params = tuple([b'-CreationDate=2025:07:09', b'-Description=anything Here \n-',])
param_tuple = (*params, pic)

with exiftool.ExifTool() as exif_handle:
    exif_handle.execute(*param_tuple)

this makes the lib wait for an stdout forever.

aw_stdout = _read_fd_endswith(fdout, seq_ready.encode(self._encoding), self._block_size)

# when it's ready, we can safely read all of stderr out, as the command is already done
fderr = self._process.stderr.fileno()
raw_stderr = _read_fd_endswith(fderr, seq_err_post.encode(self._encoding), self._block_size)

Proposed solution:

  • Adding a timeout to _read_fd_endswith and adding a try/except to the stdout so the lib can then read the stderr in case exiftool fails.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions