Я пытаюсь запустить приложение на python herok flask с помощью redis.Однако я сталкиваюсь со следующей ошибкой:
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 вылетает с вышеуказанной ошибкой (из-за тайм-аута), но фоновые процессы продолжат выполняться.Есть ли какой-нибудь возможный способ заблокировать веб-страницу heroku, пока не завершатся задачи в фоновой очереди redis?Ниже мой код для вашей справки.Обратите внимание, что я пытаюсь завершить несколько задач Redis в очереди, прежде чем вернуть шаблон results.html.
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')
Заранее благодарю за помощь.