Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

keep graceful shutdown from interrupting workers

When the signal.siginterrupt call is available it can be used to make
interrupted system calls (errno == EINTR) retry transparently whenever
they have not caused any side effects yet (e.g. no data read/written).
It should make shutdown more graceful.

Patch by Jonas Borgström
  • Loading branch information...
commit 4633d1aad9ffab87d7fc234c5b55de49b7e9d948 1 parent ba730b1
@tilgovi authored
Showing with 6 additions and 0 deletions.
  1. +1 −0  THANKS
  2. +5 −0 gunicorn/workers/base.py
View
1  THANKS
@@ -33,3 +33,4 @@ Masahiro Nakagawa <repeatedly@gmail.com>
Denis Bilenko <denis.bilenko@gmail.com>
Phil Schanely <phil@daylife.com>
Chris Lamb <lamby@debian.org>
+Jonas Borgström <jonas@borgstrom.se>
View
5 gunicorn/workers/base.py
@@ -110,6 +110,11 @@ def init_signals(self):
signal.signal(signal.SIGINT, self.handle_exit)
signal.signal(signal.SIGWINCH, self.handle_winch)
signal.signal(signal.SIGUSR1, self.handle_usr1)
+ # Don't let SIGQUIT and SIGUSR1 disturb active requests
+ # by interrupting system calls
+ if hasattr(signal, 'siginterrupt'): # python >= 2.6
+ signal.siginterrupt(signal.SIGQUIT, False)
+ signal.siginterrupt(signal.SIGUSR1, False)
def handle_usr1(self, sig, frame):
self.log.reopen_files()

0 comments on commit 4633d1a

Please sign in to comment.
Something went wrong with that request. Please try again.