3

I have a Flask API that is being run by gunicorn. To my knowledge and this SO link gunicorn should be handling any Broken pipe errors automatically for me which is why this error is confusing to me. Whenever the user hits the API endpoint a call to a MySQL database is made with SQLAlchemy. I suspect that the SQLAlchemy connection is remaining open after a query but I had trouble verifying that information. I have found the following error signals in the logs for the application but have had difficulty reproducing the behaviour myself.

[INFO] Handling signal: term 
[17] [INFO] Worker exiting (pid: 17) 
[16] [INFO] Worker exiting (pid: 16) 
[24] [INFO] Worker exiting (pid: 24) 
[18] [INFO] Worker exiting (pid: 18) 
[19] [INFO] Worker exiting (pid: 19) 
[22] [INFO] Worker exiting (pid: 22) 
[23] [INFO] Worker exiting (pid: 23) 
[20] [INFO] Worker exiting (pid: 20) 
[21] [INFO] Worker exiting (pid: 21) 
[1] [INFO] Shutting down: Master 
ERROR:sqlalchemy.pool.impl.QueuePool:Exception during reset or similar
BrokenPipeError: [Errno 32] Broken pipe

Why might this behaviour not be handled when a user disconnects prematurely and how would I verify what connections remain open on the program terminating?

Josh Zwiebel
  • 883
  • 1
  • 9
  • 30

1 Answers1

0

The log says your Gunicorn is receiving the termination signal. There's nothing to really handle as things are dying.

Gunicorn will handle a broken pipe if it happens during a regular request.

AKX
  • 152,115
  • 15
  • 115
  • 172