0

I've got a GAE Flex/Flask/Python app. I do some processing that is usually very quick, but sometimes it exceeds gunicorn's timeout, and my app displays this very ugly response:

502 Bad Gateway 
----------
nginx

I would like to catch these gunicorn errors and instead display a much more user friendly error message with Flask.

My Flask code is wrapped in a try/except block like this:

try:
    do_processing()
except Exception:
    show_error_msg()

but my code never gets to show_error_msg().

I was hoping someone had a good solution for this.

new name
  • 15,861
  • 19
  • 68
  • 114
  • Can't you increase `gunicorn`'s timeout? https://stackoverflow.com/questions/10855197/gunicorn-worker-timeout-error – Shiva Sep 08 '19 at 19:46
  • Probably a strong case here for investigating job queues like `rq` or `celery`. Heavy processing then gets done in a background task, away from the wsgi process. – v25 Sep 09 '19 at 03:27
  • @v25, that's a good suggestion. I could submit the request using AJAX on the front end. That might be easier for me. – new name Sep 09 '19 at 14:17

0 Answers0