【发布时间】:2019-07-30 00:56:22
【问题描述】:
我正在尝试使用 redis 运行 heroku flask python 应用程序。但是,我面临以下错误:
at=error code=H12 desc="Request timeout" method=POST path="/uploaderlocal" host=a2n.herokuapp.com dyno=web.1 connect=1ms service=31890ms status=503 bytes=0 protocol=https
heroku 网页因上述错误而崩溃(由于超时),但后台进程将继续运行。在redis后台队列中的任务完成之前,是否有任何可能的方法来停止heroku网页?以下是我的代码供您参考。请注意,我正在尝试在返回 results.html 模板之前完成多个 redis 排队任务。
from rq import Queue
from worker import conn
from rq.job import Job
app = Flask(__name__)
q = Queue(connection=conn)
job1 = q.enqueue_call(func=method1(), args=(), timeout='1h')
job2 = q.enqueue_call(func=method2(), args=(), timeout='1h')
job3 = q.enqueue_call(func=method3(), args=(), timeout='1h')
job4 = q.enqueue_call(func=method4(), args=(), timeout='1h')
the below code attempts (but fails) to stall the return of the #html template before the processes are finished
while(len(q)>0):
time.sleep(1)
return render_template('result.html')
提前感谢您的帮助。
【问题讨论】:
-
我只是想澄清我的问题。我在问是否有办法检查redis队列任务何时成功完成,以便在所有排队任务完成后我可以适当地继续。