27

Gunicorn is sometimes crashing my server, actually exiting the Python interpreter with sys.exit(1)! Why is this? Note that the failure is not always at the same point. In the two cases shown below, there is a different last codeline before gunicorn's exit. This code running here is openpyxl , which should not be causing interpreter shutdown!

Is the server running out of memory? Some other cause?

(This is Flask on Gunicorn on Docker in Google Container Engine.)

Case 1

  File "/virtualenv_for_docker/lib/python3.7/site-packages/openpyxl/descriptors/base.py", line 166, in __set__
    super(Bool, self).__set__(instance, value)
  File "/virtualenv_for_docker/lib/python3.7/site-packages/gunicorn/workers/base.py", line 196, in handle_abort
    sys.exit(1)
SystemExit: 1

Case 2

  File "/virtualenv_for_docker/lib/python3.7/site-packages/openpyxl/descriptors/serialisable.py", line 164, in __eq__
    def __eq__(self, other):
  File "/virtualenv_for_docker/lib/python3.7/site-packages/gunicorn/workers/base.py", line 196, in handle_abort
    sys.exit(1)
SystemExit: 1
Charlie Clark
  • 18,477
  • 4
  • 49
  • 55
Joshua Fox
  • 18,704
  • 23
  • 87
  • 147
  • 1
    Looks like the server is catching a SIGABRT: https://github.com/benoitc/gunicorn/blob/master/gunicorn/workers/base.py#L169-L195 – maxm Oct 25 '18 at 16:06
  • Hello. I am currently facing the same issue, can you please tell what was your solution? I tried increasing the timeout parameter value but still faced the same issue. Running Flask + Gunicorn on Azure Container Instance. My processing time isn't that long either. – amro_ghoneim Apr 19 '22 at 05:47
  • The solution is to ensure that the request completes faster. However, if "processing time isn't that long" then your problem may be different. – Joshua Fox Apr 19 '22 at 07:15

1 Answers1

27

As wrote @maxm the server is catching a SIGABRT, that call generally happens on timeout.

You should increase the timeout value or reduce the request processing time. Also you can setup the signal handler to try to log what happened in the worker after a timeout.

Artemij Rodionov
  • 1,721
  • 1
  • 17
  • 22
  • 1
    If you cannot reduce processing time, you can set a timeout for the function like [this](https://stackoverflow.com/a/14924210/9070016) – therealak12 Sep 29 '20 at 11:55