Skip to content

Commit

Permalink
exiftool.terminate(); kill process unconditionally
Browse files Browse the repository at this point in the history
Also don't get outs nor errs from Popen.communicate()

Fixes #63
  • Loading branch information
OdyX committed Dec 19, 2022
1 parent 0294842 commit 205364f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions exiftool/exiftool.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ def terminate(self, timeout: int = 30, _del: bool = False) -> None:
#print("before comm", self._process.poll(), self._process)
self._process.poll()
# TODO freezes here on windows if subprocess zombie remains
outs, errs = self._process.communicate() # have to cleanup the process or else .poll() will return None
self._process.communicate() # have to cleanup the process or else .poll() will return None
#print("after comm")
# TODO a bug filed with Python, or user error... this doesn't seem to work at all ... .communicate() still hangs
# https://bugs.python.org/issue43784 ... Windows-specific issue affecting Python 3.8-3.10 (as of this time)
Expand All @@ -844,11 +844,10 @@ def terminate(self, timeout: int = 30, _del: bool = False) -> None:
On Linux, this runs as is, and the process terminates properly
"""
self._process.communicate(input=b"-stay_open\nFalse\n", timeout=timeout) # this is a constant sequence specified by PH's exiftool
self._process.kill()
except subprocess.TimeoutExpired: # this is new in Python 3.3 (for python 2.x, use the PyPI subprocess32 module)
self._process.kill()
outs, errs = self._process.communicate()
# err handling code from https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate
pass
# In any case, kill the process.
self._process.kill()

self._flag_running_false()

Expand Down

0 comments on commit 205364f

Please sign in to comment.