reduce overhead of gevent.idle() by only yielding once per 1000 segments

pull/389/head
Mike Lang 1 year ago committed by Mike Lang
parent 7e90346b87
commit 1857a998c9

@ -535,10 +535,11 @@ def fast_cut_range(segments, start, end, fixts=None):
first = segments[0] if cut_start else None
last = segments[-1] if cut_end else None
for segment in segments:
for i, segment in enumerate(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 i % 1000 == 0:
gevent.idle()
if segment is None:
logging.debug("Skipping discontinuity while cutting")

@ -69,9 +69,10 @@ def generate_media(segments, base_url):
if segments and segments[0] is None:
segments = segments[1:]
for segment in segments:
for i, segment in enumerate(segments):
# For very large playlists, give other things a chance to run
gevent.idle()
if i % 1000 == 0:
gevent.idle()
if segment is None:
# Discontinuity. Adding this tag tells the client that we've missed something
# and it should start decoding fresh on the next segment. This is required when

Loading…
Cancel
Save