forked from kenzuya/unshackle
fix(serve): lock shared session state and throttle progress writes
Handlers share one service instance, so a per-session lock keeps two requests out of it at once. Track threads merge and write job state under one lock, and the progress sink coalesces ticks that say the same thing.
This commit is contained in:
@@ -1022,7 +1022,8 @@ class HLS:
|
||||
if isinstance(track, Subtitle):
|
||||
segment_file_ext = get_extension(segment.uri) or ""
|
||||
segment_file_path = segment_save_dir / f"{str(i).zfill(name_len)}{segment_file_ext}"
|
||||
segment_data = try_ensure_utf8(segment_file_path.read_bytes())
|
||||
original_data = segment_file_path.read_bytes()
|
||||
segment_data = try_ensure_utf8(original_data)
|
||||
if track.codec not in (Subtitle.Codec.fVTT, Subtitle.Codec.fTTML):
|
||||
segment_data = (
|
||||
segment_data.decode("utf8")
|
||||
@@ -1030,7 +1031,8 @@ class HLS:
|
||||
.replace("‏", html.unescape("‏"))
|
||||
.encode("utf8")
|
||||
)
|
||||
segment_file_path.write_bytes(segment_data)
|
||||
if segment_data != original_data:
|
||||
segment_file_path.write_bytes(segment_data)
|
||||
|
||||
if segment.discontinuity and i != 0:
|
||||
if encryption_data:
|
||||
@@ -1210,7 +1212,11 @@ class HLS:
|
||||
if binaries.FFMPEG:
|
||||
try:
|
||||
demuxer_file = save_path.parent / f"ffmpeg_concat_demuxer_{save_path.stem}.txt"
|
||||
demuxer_file.write_text("\n".join([f"file '{segment.absolute()}'" for segment in segments]))
|
||||
demuxer_file.write_text(
|
||||
"\n".join([f"file '{segment.absolute()}'" for segment in segments]),
|
||||
encoding="utf-8",
|
||||
newline="",
|
||||
)
|
||||
|
||||
concat_start = time.monotonic()
|
||||
subprocess.run(
|
||||
|
||||
Reference in New Issue
Block a user