Added locking to exiftool

This commit is contained in:
Rhet Turnbull
2023-04-01 19:07:31 -07:00
parent d8c7d45056
commit 81127b6d89

View File

@@ -17,6 +17,7 @@ import pathlib
import re import re
import shutil import shutil
import subprocess import subprocess
import threading
from abc import ABC, abstractmethod from abc import ABC, abstractmethod
from functools import lru_cache # pylint: disable=syntax-error from functools import lru_cache # pylint: disable=syntax-error
@@ -249,6 +250,7 @@ class ExifTool:
self._exiftoolproc = _ExifToolProc( self._exiftoolproc = _ExifToolProc(
exiftool=exiftool, large_file_support=large_file_support exiftool=exiftool, large_file_support=large_file_support
) )
self._lock = threading.Lock()
self._read_exif() self._read_exif()
@property @property
@@ -352,6 +354,7 @@ class ExifTool:
if not commands: if not commands:
raise TypeError("must provide one or more command to run") raise TypeError("must provide one or more command to run")
with self._lock:
if self._context_mgr and self.overwrite: if self._context_mgr and self.overwrite:
commands = list(commands) commands = list(commands)
commands.append("-overwrite_original") commands.append("-overwrite_original")