ffthumb only gets one shot

This commit is contained in:
ed 2021-05-29 12:32:51 +02:00
parent 97be495861
commit d8fd82bcb5
2 changed files with 13 additions and 3 deletions

View file

@ -8,7 +8,7 @@ import threading
import subprocess as sp
from .__init__ import PY2
from .util import fsenc, Queue, Cooldown, BytesIO
from .util import fsenc, mchkcmd, Queue, Cooldown, BytesIO
from .mtag import HAVE_FFMPEG, HAVE_FFPROBE, ffprobe
@ -299,8 +299,7 @@ class ThumbSrv(object):
cmd += [fsenc(tpath)]
p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
p.communicate()
mchkcmd(*cmd)
def poke(self, tdir):
if not self.poke_cd.poke(tdir):

View file

@ -985,6 +985,17 @@ def chkcmd(*argv):
return sout, serr
def mchkcmd(*argv, timeout=10):
if PY2:
with open(os.devnull, "wb") as f:
rv = sp.call(argv, stdout=f, stderr=f)
else:
rv = sp.call(argv, stdout=sp.DEVNULL, stderr=sp.DEVNULL, timeout=timeout)
if rv:
raise sp.CalledProcessError(rv, (argv[0], b"...", argv[-1]))
def gzip_orig_sz(fn):
with open(fsenc(fn), "rb") as f:
f.seek(-4, 2)