mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
put creation of worker in its own class so we can pass custom workers to
it.
This commit is contained in:
parent
f75a413773
commit
5bb0734532
@ -344,6 +344,9 @@ class Arbiter(object):
|
|||||||
if worker.age < age:
|
if worker.age < age:
|
||||||
pid, age = wpid, worker.age
|
pid, age = wpid, worker.age
|
||||||
self.kill_worker(pid, signal.SIGQUIT)
|
self.kill_worker(pid, signal.SIGQUIT)
|
||||||
|
|
||||||
|
def init_worker(self, worker_age, pid, listener, app, timeout, conf):
|
||||||
|
return Worker(worker_age, pid, listener, app, timeout, conf)
|
||||||
|
|
||||||
def spawn_workers(self):
|
def spawn_workers(self):
|
||||||
"""\
|
"""\
|
||||||
@ -355,8 +358,8 @@ class Arbiter(object):
|
|||||||
|
|
||||||
for i in range(self.num_workers - len(self.WORKERS.keys())):
|
for i in range(self.num_workers - len(self.WORKERS.keys())):
|
||||||
self.worker_age += 1
|
self.worker_age += 1
|
||||||
worker = Worker(self.worker_age, self.pid, self.LISTENER, self.app,
|
worker = self.init_worker(self.worker_age, self.pid, self.LISTENER,
|
||||||
self.timeout/2.0, self.conf)
|
self.app, self.timeout/2.0, self.conf)
|
||||||
self.conf.before_fork(self, worker)
|
self.conf.before_fork(self, worker)
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
if pid != 0:
|
if pid != 0:
|
||||||
|
|||||||
@ -93,7 +93,6 @@ class Worker(object):
|
|||||||
util.close_on_exec(self.socket)
|
util.close_on_exec(self.socket)
|
||||||
util.close_on_exec(self.fd)
|
util.close_on_exec(self.fd)
|
||||||
self.init_signals()
|
self.init_signals()
|
||||||
|
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user