Skip to content

Commit

Permalink
Merge pull request #1257 from benoitc/fix/1256
Browse files Browse the repository at this point in the history
unblock the wait loop under python 3.5
  • Loading branch information
benoitc committed May 10, 2016
2 parents 9d158be + b0c0333 commit 58f190d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions gunicorn/workers/base.py
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down
5 changes: 4 additions & 1 deletion gunicorn/workers/sync.py
Expand Up @@ -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]

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 58f190d

Please sign in to comment.