fix: 编号进度改为单线程写入并在任务上显示原因
This commit is contained in:
@@ -971,7 +971,7 @@ async def run_download(job: DownloadJob) -> None:
|
||||
await _mark(job, "error", message, "error")
|
||||
else:
|
||||
logger.exception("下载任务失败 job=%s", job.id)
|
||||
await _mark(job, "error", "下载失败,详情见日志", "error")
|
||||
await _mark(job, "error", "下载中断,已下载的内容还在,点继续即可", "error")
|
||||
finally:
|
||||
if spool is not None:
|
||||
await asyncio.to_thread(spool.close)
|
||||
@@ -1074,10 +1074,9 @@ async def _run_city(job: DownloadJob, journal: CsvJournal, columns, service_code
|
||||
|
||||
# 补读失败块或继续全量扫描时,先取消“已读完”,下载侧才会等新编号。
|
||||
tiles = retry if spool.complete else None
|
||||
spool.complete = False
|
||||
job.listing_done = False
|
||||
job.failed_tiles = []
|
||||
spool.failed_tiles = []
|
||||
spool.set_scan_state(complete=False, failed_tiles=[])
|
||||
|
||||
async def listing() -> None:
|
||||
async def report(count: int) -> None:
|
||||
@@ -1110,16 +1109,16 @@ async def _run_city(job: DownloadJob, journal: CsvJournal, columns, service_code
|
||||
if spool.due():
|
||||
await asyncio.to_thread(spool.flush)
|
||||
except NqiAuthError:
|
||||
spool.failed_tiles = [list(item) for item in job.failed_tiles]
|
||||
spool.set_scan_state(failed_tiles=job.failed_tiles)
|
||||
await asyncio.to_thread(spool.flush)
|
||||
raise
|
||||
except NqiError as exc:
|
||||
spool.failed_tiles = [list(item) for item in job.failed_tiles]
|
||||
spool.set_scan_state(failed_tiles=job.failed_tiles)
|
||||
await asyncio.to_thread(spool.flush)
|
||||
if job.cancel_event.is_set() or str(exc) == "已停止":
|
||||
return
|
||||
raise
|
||||
spool.failed_tiles = [list(item) for item in job.failed_tiles]
|
||||
spool.set_scan_state(failed_tiles=job.failed_tiles)
|
||||
if job.cancel_event.is_set() or job.retune.is_set():
|
||||
await asyncio.to_thread(spool.flush)
|
||||
return
|
||||
@@ -1210,7 +1209,7 @@ async def _pump(job: DownloadJob, client, journal, columns, service_code: str, s
|
||||
if fatal is not None:
|
||||
raise fatal
|
||||
logger.exception("栅格下载失败 id=%s", grid_id)
|
||||
error = "下载失败,详情见日志"
|
||||
error = explain_os_error(exc) or "这个栅格暂时下载失败"
|
||||
if attempt == 0:
|
||||
await asyncio.sleep(0.4)
|
||||
if rows is None:
|
||||
|
||||
Reference in New Issue
Block a user