diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index 94c2505fd..d187a611a 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -113,6 +113,8 @@ def changed(fname): [util.close_on_exec(s) for s in self.sockets] util.close_on_exec(self.tmp.fileno()) + self.wait_fds = self.sockets + [self.PIPE[0]] + self.log.close_on_exec() self.init_signals() @@ -164,6 +166,9 @@ def init_signals(self): signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False) + if hasattr(signal, 'set_wakeup_fd'): + signal.set_wakeup_fd(self.PIPE[1]) + def handle_usr1(self, sig, frame): self.log.reopen_files() diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 15ac08432..82943dec3 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -32,7 +32,7 @@ def accept(self, listener): def wait(self, timeout): try: self.notify() - ret = select.select(self.sockets, [], self.PIPE, timeout) + ret = select.select(self.wait_fds, [], [], timeout) if ret[0]: return ret[0] @@ -93,6 +93,9 @@ def run_for_multiple(self, timeout): if ready is not None: for listener in ready: + if listener == self.PIPE[0]: + continue + try: self.accept(listener) except EnvironmentError as e: