Skip to content

Commit

Permalink
[arbiter] close sockets on shutdown
Browse files Browse the repository at this point in the history
Close all the listeners when the arbiter shuts down. By doing so,
workers can close the socket at the beginning of a graceful shut
down thereby informing the operating system that the socket can
be cleaned up. With this change, graceful exits with such workers
will refuse new connections while draining, allowing load balancers
to respond more quickly and avoiding leaving connections dangling
in the listen backlog, unaccepted.

Ref #922
  • Loading branch information
tilgovi committed Mar 13, 2016
1 parent e05941c commit 04d6547
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gunicorn/arbiter.py
Expand Up @@ -334,6 +334,8 @@ def stop(self, graceful=True):
:attr graceful: boolean, If True (the default) workers will be
killed gracefully (ie. trying to wait for the current connection)
"""
for l in self.LISTENERS:
l.close()
self.LISTENERS = []
sig = signal.SIGTERM
if not graceful:
Expand Down

0 comments on commit 04d6547

Please sign in to comment.