(idx, input_data)
| 745 | file_write_lock = asyncio.Lock() |
| 746 | |
| 747 | async def worker(idx, input_data): |
| 748 | async with semaphore: |
| 749 | result = await self._evaluate_one(input_data) |
| 750 | results[idx] = result |
| 751 | if output_path: |
| 752 | async with file_write_lock: |
| 753 | with open(output_path, "a", encoding="utf-8") as f: |
| 754 | try: |
| 755 | f.write(json.dumps(result, ensure_ascii=False) + "\n") |
| 756 | except Exception as e: |
| 757 | print(f"❌ 写入结果失败: {e}") |
| 758 | print(f"❌ 写入结果: {result}") |
| 759 | |
| 760 | # 任务完成时立即更新进度条 |
| 761 | async with progress_lock: |
| 762 | progress_bar.update(1) |
| 763 | |
| 764 | # 创建所有任务 |
| 765 | tasks = [worker(idx, input_data) for idx, input_data in enumerate(input_list)] |
nothing calls this directly
no test coverage detected