mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Fix USR1 handling in workers.
This commit is contained in:
parent
9dde33c15c
commit
84d4510847
@ -338,7 +338,7 @@ class Arbiter(object):
|
||||
continue
|
||||
|
||||
worker = Worker(i, self.pid, self.LISTENER, self.modname,
|
||||
self.timeout/2, self.PIPE, self.debug)
|
||||
self.timeout/2, self.debug)
|
||||
pid = os.fork()
|
||||
if pid != 0:
|
||||
self.WORKERS[pid] = worker
|
||||
|
||||
@ -27,8 +27,7 @@ class Worker(object):
|
||||
|
||||
PIPE = []
|
||||
|
||||
def __init__(self, workerid, ppid, socket, app,
|
||||
timeout, pipe, debug=False):
|
||||
def __init__(self, workerid, ppid, socket, app, timeout, debug=False):
|
||||
self.nr = 0
|
||||
self.id = workerid
|
||||
self.ppid = ppid
|
||||
@ -44,9 +43,9 @@ class Worker(object):
|
||||
self.spinner = 0
|
||||
|
||||
# init pipe
|
||||
self.PIPE = pipe
|
||||
map(util.set_non_blocking, pipe)
|
||||
map(util.close_on_exec, pipe)
|
||||
self.PIPE = os.pipe()
|
||||
map(util.set_non_blocking, self.PIPE)
|
||||
map(util.close_on_exec, self.PIPE)
|
||||
|
||||
# prevent inherientence
|
||||
util.close_on_exec(self.socket)
|
||||
@ -65,7 +64,8 @@ class Worker(object):
|
||||
signal.signal(signal.SIGINT, self.handle_exit)
|
||||
|
||||
def handle_usr1(self, sig, frame):
|
||||
self.nr = -65536;
|
||||
self.log.info("USR1")
|
||||
self.nr = -65536;
|
||||
try:
|
||||
map(lambda p: p.close(), self.PIPE)
|
||||
except:
|
||||
@ -106,10 +106,9 @@ class Worker(object):
|
||||
if e[0] not in (errno.EAGAIN, errno.ECONNABORTED):
|
||||
raise
|
||||
|
||||
# Accept until we hit EAGAIN. We're betting that when we're
|
||||
# processing clients that more clients are waiting. When
|
||||
# there's no more clients waiting we go back to the select()
|
||||
# loop and wait for some lovin.
|
||||
# Keep processing clients until no one is waiting.
|
||||
# This prevents the need to select() for every
|
||||
# client that we process.
|
||||
if self.nr > 0:
|
||||
continue
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user