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,9 +535,10 @@ def fast_cut_range(segments, start, end, fixts=None):
first = segments[0] if cut_start else None first = segments[0] if cut_start else None
last = segments[-1] if cut_end 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, # Since long smart cuts can be CPU and disk bound for quite a while,
# yield to give other things a chance to run. # yield to give other things a chance to run.
if i % 1000 == 0:
gevent.idle() gevent.idle()
if segment is None: if segment is None:

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

Loading…
Cancel
Save