mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Don't use a list comprehension as shorthand for a for loop.
This commit is contained in:
parent
72dd0199d7
commit
5b89fe1beb
@ -173,8 +173,8 @@ class Arbiter(object):
|
|||||||
are queued. Child signals only wake up the master.
|
are queued. Child signals only wake up the master.
|
||||||
"""
|
"""
|
||||||
# close old PIPE
|
# close old PIPE
|
||||||
if self.PIPE:
|
for p in self.PIPE:
|
||||||
[os.close(p) for p in self.PIPE]
|
os.close(p)
|
||||||
|
|
||||||
# initialize the pipe
|
# initialize the pipe
|
||||||
self.PIPE = pair = os.pipe()
|
self.PIPE = pair = os.pipe()
|
||||||
@ -185,7 +185,8 @@ class Arbiter(object):
|
|||||||
self.log.close_on_exec()
|
self.log.close_on_exec()
|
||||||
|
|
||||||
# initialize all signals
|
# initialize all signals
|
||||||
[signal.signal(s, self.signal) for s in self.SIGNALS]
|
for s in self.SIGNALS:
|
||||||
|
signal.signal(s, self.signal)
|
||||||
signal.signal(signal.SIGCHLD, self.handle_chld)
|
signal.signal(signal.SIGCHLD, self.handle_chld)
|
||||||
|
|
||||||
def signal(self, sig, frame):
|
def signal(self, sig, frame):
|
||||||
@ -454,7 +455,8 @@ class Arbiter(object):
|
|||||||
# do we need to change listener ?
|
# do we need to change listener ?
|
||||||
if old_address != self.cfg.address:
|
if old_address != self.cfg.address:
|
||||||
# close all listeners
|
# close all listeners
|
||||||
[l.close() for l in self.LISTENERS]
|
for l in self.LISTENERS:
|
||||||
|
l.close()
|
||||||
# init new listeners
|
# init new listeners
|
||||||
self.LISTENERS = sock.create_sockets(self.cfg, self.log)
|
self.LISTENERS = sock.create_sockets(self.cfg, self.log)
|
||||||
listeners_str = ",".join([str(l) for l in self.LISTENERS])
|
listeners_str = ",".join([str(l) for l in self.LISTENERS])
|
||||||
|
|||||||
@ -101,7 +101,8 @@ class Worker(object):
|
|||||||
util.close_on_exec(p)
|
util.close_on_exec(p)
|
||||||
|
|
||||||
# Prevent fd inheritance
|
# Prevent fd inheritance
|
||||||
[util.close_on_exec(s) for s in self.sockets]
|
for s in self.sockets:
|
||||||
|
util.close_on_exec(s)
|
||||||
util.close_on_exec(self.tmp.fileno())
|
util.close_on_exec(self.tmp.fileno())
|
||||||
|
|
||||||
self.wait_fds = self.sockets + [self.PIPE[0]]
|
self.wait_fds = self.sockets + [self.PIPE[0]]
|
||||||
@ -156,7 +157,8 @@ class Worker(object):
|
|||||||
|
|
||||||
def init_signals(self):
|
def init_signals(self):
|
||||||
# reset signaling
|
# reset signaling
|
||||||
[signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS]
|
for s in self.SIGNALS:
|
||||||
|
signal.signal(s, signal.SIG_DFL)
|
||||||
# init new signaling
|
# init new signaling
|
||||||
signal.signal(signal.SIGQUIT, self.handle_quit)
|
signal.signal(signal.SIGQUIT, self.handle_quit)
|
||||||
signal.signal(signal.SIGTERM, self.handle_exit)
|
signal.signal(signal.SIGTERM, self.handle_exit)
|
||||||
|
|||||||
@ -134,9 +134,12 @@ class EventletWorker(AsyncWorker):
|
|||||||
self.notify()
|
self.notify()
|
||||||
try:
|
try:
|
||||||
with eventlet.Timeout(self.cfg.graceful_timeout) as t:
|
with eventlet.Timeout(self.cfg.graceful_timeout) as t:
|
||||||
[a.kill(eventlet.StopServe()) for a in acceptors]
|
for a in acceptors:
|
||||||
[a.wait() for a in acceptors]
|
a.kill(eventlet.StopServe())
|
||||||
|
for a in acceptors:
|
||||||
|
a.wait()
|
||||||
except eventlet.Timeout as te:
|
except eventlet.Timeout as te:
|
||||||
if te != t:
|
if te != t:
|
||||||
raise
|
raise
|
||||||
[a.kill() for a in acceptors]
|
for a in acceptors:
|
||||||
|
a.kill()
|
||||||
|
|||||||
@ -143,7 +143,8 @@ class GeventWorker(AsyncWorker):
|
|||||||
|
|
||||||
# Force kill all active the handlers
|
# Force kill all active the handlers
|
||||||
self.log.warning("Worker graceful timeout (pid:%s)" % self.pid)
|
self.log.warning("Worker graceful timeout (pid:%s)" % self.pid)
|
||||||
[server.stop(timeout=1) for server in servers]
|
for server in servers:
|
||||||
|
server.stop(timeout=1)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user