Skip to content

Gunicorn doesn't shutdown immediately on receiving SIGTERM #1256

@suriya

Description

@suriya

I am seeing a weird behavior where Gunicorn does not shutdown immediately when sent a SIGTERM. I see this with Python 3.5 on Ubuntu 16.04. The following environments (that I have access to) do not exhibit this issue:

  • Python 2.7 on Ubuntu 16.04
  • Python 2.7 on Ubuntu 14.04
  • Python 3.4 on Ubuntu 14.04

Refer to https://gist.github.com/suriya/1d9a11ea9ad33a5b1df0b2ba7ed0cd0e on how to reproduce this issue.

After debugging a while, I found that the Gunicorn arbiter properly signals the child worker. The child workers handle the signal properly as well (on all versions). However, something prevents the loop in run_for_one function

while self.alive:
from exiting right away with Python 3.5.

Could Python 3.5's change in the behavior of select.select() https://docs.python.org/3/library/select.html#select.select explain this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature/Workerbug :(help wantedOpen for everyone. You do not need permission to work on these. May need familiarity with codebase.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions