fix: 评估任务正在取工参时补取任务一分钟后再来,不用等定时检查;工作区没就绪时把页面文字记进日志
This commit is contained in:
@@ -43,12 +43,14 @@ def decom_gongcan_sync(city: str) -> None:
|
||||
execute_sync(city)
|
||||
|
||||
|
||||
def defer(name: str, *, queueing_lock: str | None = None, **kwargs) -> bool:
|
||||
"""排一个任务。queueing_lock 相同的任务已有一个在排队时不再排,返回 False。"""
|
||||
def defer(name: str, *, queueing_lock: str | None = None, delay: int = 0, **kwargs) -> bool:
|
||||
"""排一个任务,delay 秒后才执行。queueing_lock 相同的任务已有一个在排队时不再排,返回 False。"""
|
||||
# API 和 worker 是两个进程;worker 自己还会从后台线程提交采集任务。
|
||||
# 使用独立的同步连接,避免与 worker 持有的异步连接互相关闭。
|
||||
# 几个线程会同时来排任务;连接池由先到的打开、退出时关闭,不加锁后到的会用到已关闭的池。
|
||||
options = {"queueing_lock": queueing_lock} if queueing_lock else {}
|
||||
options: dict = {"queueing_lock": queueing_lock} if queueing_lock else {}
|
||||
if delay > 0:
|
||||
options["schedule_in"] = {"seconds": delay}
|
||||
with _defer_lock, defer_queue.open():
|
||||
try:
|
||||
defer_queue.configure_task(name, queue="decom", **options).defer(**kwargs)
|
||||
|
||||
Reference in New Issue
Block a user