@@ -309,7 +309,7 @@ async def _upload(item: dict, task_length: int):
309
309
break
310
310
311
311
elif res ["result" ] in ["doing" ]: # doing / other
312
- if (now - begin ).seconds > 5 * 60 : # 超时
312
+ if (now - begin ).seconds > 2 * 60 : # 超时
313
313
update_status (
314
314
id = item ["id" ],
315
315
status = "上传失败,代码上传密钥疑似错误" ,
@@ -392,46 +392,52 @@ async def _task():
392
392
"成功" not in (x ["status" ] or "" ),
393
393
not x ["upload_at" ],
394
394
"失败" not in (x ["status" ] or "" ),
395
- x ["create_at" ] ,
395
+ x ["upload_at" ] or MIN_TIME ,
396
396
),
397
397
reverse = True ,
398
398
)
399
399
logging .info (
400
400
f"当前任务总数 { len (_list2 )} ,未完成任务数 { len (_list3 )} ,本轮处理任务数 { len (_list )} "
401
401
)
402
402
403
- for index , item in enumerate (_list ):
404
- item ["task-index" ] = index + 1
405
- await asyncio .sleep (0.1 )
403
+ async def _upload_task (_list ):
404
+ for index , item in enumerate (_list ):
405
+ item ["task-index" ] = index + 1
406
+ await asyncio .sleep (0.1 )
406
407
407
- if len (item ["appid" ]) != 18 :
408
- update_status (id = item ["id" ], status = "校验失败,AppID不是18位" )
409
- continue
410
- if len (item ["mobile" ]) != 11 :
411
- update_status (id = item ["id" ], status = "校验失败,手机号不是11位" )
412
- continue
413
- if len (item ["key" ]) < 1000 :
414
- update_status (id = item ["id" ], status = "校验失败,代码上传密钥明细错误" )
415
- continue
416
- item ["key" ] = _handle_key (item )
417
- if not item ["key" ]:
418
- update_status (id = item ["id" ], status = "校验失败,无效的代码上传密钥" )
419
- continue
408
+ if len (item ["appid" ]) != 18 :
409
+ update_status (id = item ["id" ], status = "校验失败,AppID不是18位" )
410
+ continue
411
+ if len (item ["mobile" ]) != 11 :
412
+ update_status (id = item ["id" ], status = "校验失败,手机号不是11位" )
413
+ continue
414
+ if len (item ["key" ]) < 1000 :
415
+ update_status (
416
+ id = item ["id" ], status = "校验失败,代码上传密钥明细错误"
417
+ )
418
+ continue
419
+ item ["key" ] = _handle_key (item )
420
+ if not item ["key" ]:
421
+ update_status (id = item ["id" ], status = "校验失败,无效的代码上传密钥" )
422
+ continue
420
423
421
- await _auth_check (item )
424
+ await _auth_check (item )
422
425
423
- try :
424
- await asyncio .wait_for (_upload (item , len (_list )), timeout = 5 * 60 )
425
- except asyncio .TimeoutError :
426
- continue
426
+ try :
427
+ await asyncio .wait_for (_upload (item , len (_list )), timeout = 3 * 60 )
428
+ except asyncio .TimeoutError :
429
+ continue
430
+
431
+ try :
432
+ await asyncio .wait_for (_upload_task (_list ), timeout = len (_list ) * 3 * 60 )
433
+ except asyncio .TimeoutError :
434
+ logging .info ("任务处理超时" )
427
435
428
436
logging .info ("任务处理完成" )
429
437
430
438
while True :
431
439
try :
432
- await asyncio .wait_for (_task (), timeout = 2 * 3600 )
433
- except asyncio .TimeoutError :
434
- logging .info ("任务处理超时" )
440
+ _task ()
435
441
except Exception as e :
436
442
logging .warning (f"任务处理异常 { e } { e .__class__ .__name__ } " , exc_info = True )
437
443
else :
0 commit comments