diff --git a/app/blueprints/__pycache__/brand.cpython-312.pyc b/app/blueprints/__pycache__/brand.cpython-312.pyc index b306d2e..777482c 100644 Binary files a/app/blueprints/__pycache__/brand.cpython-312.pyc and b/app/blueprints/__pycache__/brand.cpython-312.pyc differ diff --git a/app/blueprints/brand.py b/app/blueprints/brand.py index bc15ad1..0fb67d2 100644 --- a/app/blueprints/brand.py +++ b/app/blueprints/brand.py @@ -242,9 +242,11 @@ def _background_brand_task(task_id,data): fileUrl = file_data.get("fileUrl") if not brand_ls: continue - for i in range(0, len(brand_ls), 5): - chunk = brand_ls[i:i + 5] - tasks.append((chunk, fileUrl)) + file_chunks = [brand_ls[i:i + 5] for i in range(0, len(brand_ls), 5)] + chunk_total = len(file_chunks) + 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: max_workers = min(8, len(tasks)) @@ -253,8 +255,8 @@ def _background_brand_task(task_id,data): _push_task_event(task_id, {'status': 'cancelled'}) return futures = [ - executor.submit(_run_brand_single, task_id, chunk, file_url, strategy,len(brand_ls),len(tasks),chunkIndex+1) - for chunkIndex,(chunk, file_url) in enumerate(tasks) + executor.submit(_run_brand_single, task_id, chunk, file_url, strategy, total_lines, chunk_total, chunk_index) + for chunk, file_url, total_lines, chunk_total, chunk_index in tasks ] for future in as_completed(futures): if _is_task_cancelled(task_id):