bottle / gunicorn not responding to SIGTERM after ANY request


I have used bottle for a long time and never run into this before, but recently I started a new project and encountered some strange behaviour that I just can not track down at all.

If I start a bottle instance in my script, and send that script a SIGTERM it immediately shuts down gracefully. But if I make even a single http request any future sending of SIGTERM is shown on the screen [INFO] Handling signal: term but the script doesn’t shut down.

I was convinced at first this was my mistake somehow, that I wasn’t exiting properly from my requests, but it turns out even a 404 request, or a 405, trigger the same behaviour.

import bottle = '', port = 9000, server = 'gunicorn')

If I run this, then send SIGTERM, no problem, script exists. If I request a page and get a 404, that’s it, no more response to SIGTERM except the message saying it got the signal, but it doesn’t shut down after that.

The host and port don’t make any difference. Nor does adding successful requests. The only thing that seems to trigger the behaviour is the server = 'gunicorn' line. If I remove this, then the script acts as expected.

I’m at my wit’s end with this. I kept removing more and more code trying to understand what the problem was, until I ended up with the above, and that’s all it takes. Issue has to be between bottle and gunicorn somehow.

bottle is 0.12.25
gunicorn is 21.2.0
python is 3.10.12


Whelp, I don’t understand this even one bit, but it looks like this issue has zero to do with python, bottle, or gunicorn. I had been testing using Chrome, so on a whim I tried to make the request in Firefox, no hanging whatsoever. I can’t explain it, but it seems Chrome wasn’t closing the connection even though it received everything and displayed the output.

Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.