feat: 新增模块化Streamlit本地工具箱
This commit is contained in:
@@ -166,7 +166,7 @@ class StreamingCsvWriter:
|
||||
self.file.close()
|
||||
|
||||
|
||||
async def async_main(*, handle_signals=True):
|
||||
async def async_main(*, handle_signals=True, should_stop=None, progress=None):
|
||||
parts = urlsplit(URL.strip())
|
||||
if parts.scheme not in ("http", "https") or not parts.netloc or not COOKIES.strip():
|
||||
raise ValueError("请先在脚本顶部填写完整 URL 和 COOKIES")
|
||||
@@ -196,6 +196,9 @@ async def async_main(*, handle_signals=True):
|
||||
async def query_worker(session, selected):
|
||||
nonlocal stop_reason
|
||||
while not stop.is_set():
|
||||
if should_stop and should_stop():
|
||||
request_stop()
|
||||
break
|
||||
# 同一事件循环中读取下一行,无 await,不会并发推进 CSV 迭代器。
|
||||
point = next(selected, None)
|
||||
if point is None:
|
||||
@@ -240,6 +243,8 @@ async def async_main(*, handle_signals=True):
|
||||
status_key = {"成功": "命中坐标", "未命中": "未命中坐标"}.get(metadata["查询状态"], "失败坐标")
|
||||
counts[status_key] += 1
|
||||
counts["楼宇结果行"] += len(features)
|
||||
if progress:
|
||||
progress(dict(counts))
|
||||
if counts["查询坐标"] == 1 or counts["查询坐标"] % PROGRESS_EVERY == 0:
|
||||
print(f"已写入 {counts['查询坐标']} 个坐标,命中 {counts['命中坐标']},未命中 {counts['未命中坐标']},失败 {counts['失败坐标']}", flush=True)
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user