From cd4d08adc1556174fcb5d1388c2d305e92f2ff8d Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Thu, 16 Nov 2023 16:29:41 +1100 Subject: [PATCH] Yield after each segment when doing fast/smart cuts To avoid blocking for long periods --- common/common/segments.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/common/segments.py b/common/common/segments.py index 068dc86..2a6d35a 100644 --- a/common/common/segments.py +++ b/common/common/segments.py @@ -530,6 +530,10 @@ def fast_cut_range(segments, start, end, fixts=None): last = segments[-1] if cut_end else None for segment in segments: + # Since long smart cuts can be CPU and disk bound for quite a while, + # yield to give other things a chance to run. + gevent.idle() + if segment is None: logging.debug("Skipping discontinuity while cutting") # TODO: If we want to be safe against the possibility of codecs changing,