Files
MemRelay/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/楼宇查询改为8协程和独占写线程即时CSV落盘.md
T

21 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: 楼宇查询改为8协程和独占写线程即时CSV落盘
type: decision
permalink: main/projects/8e229c96-a83b-4a02-ac40-10a0a9da444e/楼宇查询改为-8-协程和独占写线程即时-csv-落盘
stable_id: b082f2d6-b0cc-480c-af8c-df747786ac97
scope: project
project_id: 8e229c96-a83b-4a02-ac40-10a0a9da444e
memory_type: decision
status: active
revision: 1
restored_from_commit: 6a6a895eafcca6052e81a14fca103a42635dd1c2
created_at: '2026-09-23T15:02:07.536313+00:00'
updated_at: '2026-09-23T15:02:07.536367+00:00'
tags:
- asyncio
- aiohttp
- csv
- concurrency
---
用户要求GetNRBuildingsData改成多协程异步版,允许异步库,变量控制数量默认8,写入单线程,每次结果返回即写,避免文件竞态。采用aiohttp连接池和固定数量worker,bounded asyncio.Queue传递结果,单独ThreadPoolExecutor(max_workers=1)独占CSV句柄。每次查询结果写入后flush;动态properties后续新增字段时仅写线程以临时CSV原子替换扩展表头,不再等所有查询结束。观察到用户已将本地LIMIT改为1000,需保留;本地URL/COOKIES有效默认也保持且不得提交或上传。继续保持独立脚本,不修改main.py。