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