mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-23 02:26:37 -05:00
[downloader/fragment] Fix problem where multiple threads can share one iterator
which causes "ValueError: generator already executing" error Closes #2881
This commit is contained in:
parent
15dfb3929c
commit
f0734e1190
@ -410,17 +410,16 @@ class FragmentFD(FileDownloader):
|
|||||||
def bindoj_result(future):
|
def bindoj_result(future):
|
||||||
return future.result()
|
return future.result()
|
||||||
|
|
||||||
|
def interrupt_trigger_iter(fg):
|
||||||
|
for f in fg:
|
||||||
|
if not interrupt_trigger[0]:
|
||||||
|
break
|
||||||
|
yield f
|
||||||
|
|
||||||
spins = []
|
spins = []
|
||||||
for idx, (ctx, fragments, info_dict) in enumerate(args):
|
for idx, (ctx, fragments, info_dict) in enumerate(args):
|
||||||
tpe = FTPE(math.ceil(max_workers / max_progress))
|
tpe = FTPE(math.ceil(max_workers / max_progress))
|
||||||
|
job = tpe.submit(thread_func, idx, ctx, interrupt_trigger_iter(fragments), info_dict, tpe)
|
||||||
def interrupt_trigger_iter():
|
|
||||||
for f in fragments:
|
|
||||||
if not interrupt_trigger[0]:
|
|
||||||
break
|
|
||||||
yield f
|
|
||||||
|
|
||||||
job = tpe.submit(thread_func, idx, ctx, interrupt_trigger_iter(), info_dict, tpe)
|
|
||||||
spins.append((tpe, job))
|
spins.append((tpe, job))
|
||||||
|
|
||||||
result = True
|
result = True
|
||||||
|
Loading…
Reference in New Issue
Block a user