品牌多文件chunk修复
This commit is contained in:
Binary file not shown.
@@ -242,9 +242,11 @@ def _background_brand_task(task_id,data):
|
|||||||
fileUrl = file_data.get("fileUrl")
|
fileUrl = file_data.get("fileUrl")
|
||||||
if not brand_ls:
|
if not brand_ls:
|
||||||
continue
|
continue
|
||||||
for i in range(0, len(brand_ls), 5):
|
file_chunks = [brand_ls[i:i + 5] for i in range(0, len(brand_ls), 5)]
|
||||||
chunk = brand_ls[i:i + 5]
|
chunk_total = len(file_chunks)
|
||||||
tasks.append((chunk, fileUrl))
|
total_lines = len(brand_ls)
|
||||||
|
for chunk_index, chunk in enumerate(file_chunks, start=1):
|
||||||
|
tasks.append((chunk, fileUrl, total_lines, chunk_total, chunk_index))
|
||||||
|
|
||||||
if tasks:
|
if tasks:
|
||||||
max_workers = min(8, len(tasks))
|
max_workers = min(8, len(tasks))
|
||||||
@@ -253,8 +255,8 @@ def _background_brand_task(task_id,data):
|
|||||||
_push_task_event(task_id, {'status': 'cancelled'})
|
_push_task_event(task_id, {'status': 'cancelled'})
|
||||||
return
|
return
|
||||||
futures = [
|
futures = [
|
||||||
executor.submit(_run_brand_single, task_id, chunk, file_url, strategy,len(brand_ls),len(tasks),chunkIndex+1)
|
executor.submit(_run_brand_single, task_id, chunk, file_url, strategy, total_lines, chunk_total, chunk_index)
|
||||||
for chunkIndex,(chunk, file_url) in enumerate(tasks)
|
for chunk, file_url, total_lines, chunk_total, chunk_index in tasks
|
||||||
]
|
]
|
||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
if _is_task_cancelled(task_id):
|
if _is_task_cancelled(task_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user