Open OdyX opened 1 year ago
Ok. I also have an issue with running in pytest on actual Windows. I think this might be related to the bug I reported to CPython more than a year ago. It's still open... https://github.com/python/cpython/issues/87950
You can try putting print statements in terminate()
and see if it happens at self._process.communicate()
Let's see if I understand the code in terminate()
correctly.
with ExifTool():
block, first, __exit__()
is called, which calls terminate(_del=False)
(_del
defaults to False
); hence through exiftool.py#L839-L851 I can confirm it blocks at line 850. There, on Windows, this seems it can be rewritten in a simpler way, as we want to kill the process in all cases;
try:
self._process.communicate(input=b"-stay_open\nFalse\n", timeout=timeout) # this is a constant sequence specified by PH's exiftool
except subprocess.TimeoutExpired: # this is new in Python 3.3 (for python 2.x, use the PyPI subprocess32 module)
pass
# Kill it in all cases
self._process.kill()
self._flag_running_false()
runs, unsets self._running
, and terminates__del__()
runs, but as self._running
has been unset, doesn't call terminate()
at all.In my tests, with the above simple patch, I see no lurking processes in Linux nor Windows.
I'll try this next week. But from what I remember, there bug manifests itself during del or something. I had some tests cases that caused PyExifTool to hang. I think they're still in the test code.
Trying to debug a pyexiftool issue on Windows, to which I don't have access, I'm basically trying to run this, in tobix/pywine:
I run this in the following command:
With various
print
s andpytest
options, I can see that theget_metadata
call works, and thatassert len(d) > 0
passes, but the code never goes past the end of thewith
block. In other words, it hangs in.terminate()
, and never goes to test ExifTool.Now. If I add a
import pdb; pdb.set_trace()
as first line in the function, and hitc
when prompted, it works. What am I doing wrong?