我有一个小型 Web 应用程序,它处理后台任务。该任务需要 5 分钟才能完成。所以我使用了调度程序。
我已将调度程序配置为 ubuntu 机器中的服务。
[Unit]
Description=Web2Py scheduler service
[Service]
ExecStart=/usr/bin/python /home/www-data/web2py/web2py.py -K myapp
Type=simple
[Install]
WantedBy=multi-user.target
现在这是一个 web 应用程序,长时间运行的进程是从 UI 启动的。现在,当从多个浏览器启动此过程时,调度程序似乎会按顺序等待任务按触发顺序完成。
您能否给我建议一下方法,以便调度程序在看到任务的那一刻立即开始执行作业。
截至目前,我正在以这种方式启动任务:
def initiate_fileprocess(proc_row_id):
#code to parse and return result
scheduler.queue_task(initiate_fileprocess, pvars=dict(proc_row_id=proc_row_id), timeout=3600)