Heroku app runs locally but gets H12 timeout error (uses a package)
--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Heroku App Runs Locally But Gets H12 Timeout Error (Uses A Package)
01:52 Accepted Answer Score 14
02:23 Thank you
--
Full question
https://stackoverflow.com/questions/1602...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #heroku #flask #gunicorn
#avk47
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Meditation
--
Chapters
00:00 Heroku App Runs Locally But Gets H12 Timeout Error (Uses A Package)
01:52 Accepted Answer Score 14
02:23 Thank you
--
Full question
https://stackoverflow.com/questions/1602...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #heroku #flask #gunicorn
#avk47
ACCEPTED ANSWER
Score 14
The issue is that run.py unguardedly calls app.run - this actually calls werkzeug.serving.run_simple which starts a sub-process to handle incoming requests ... which you don't want to do when running under gunicorn (since gunicorn will handle the process management for you).
Simply add an if __name__ == "__main__" guard before your app.run call and everything should work:
# run.py
if __name__ == "__main__":
app.run()