better handling of QUIT/HUP soignal to fix issue #49. We want graceful

quit or restart if possible.
This commit is contained in:
benoitc 2010-05-10 12:25:34 +02:00
parent ba06498d7d
commit 2bc67cc8b8
3 changed files with 5 additions and 4 deletions

View File

@ -103,7 +103,6 @@ class Worker(object):
def handle_quit(self, sig, frame):
self.alive = False
os._exit(3)
def handle_exit(self, sig, frame):
self.alive = False

View File

@ -38,7 +38,7 @@ class EventletWorker(AsyncWorker):
pool = greenpool.GreenPool(self.worker_connections)
acceptor = greenthread.spawn(self.acceptor, pool)
while True:
while self.alive:
self.notify()
if self.ppid != os.getppid():
@ -50,10 +50,11 @@ class EventletWorker(AsyncWorker):
with eventlet.Timeout(self.timeout, False):
pool.waitall()
os._exit(3)
def acceptor(self, pool):
greenthread.getcurrent()
while True:
while self.alive:
try:
conn, addr = self.socket.accept()
gt = pool.spawn(self.handle, conn, addr)

View File

@ -35,7 +35,7 @@ class GEventWorker(AsyncWorker):
acceptor = gevent.spawn(self.acceptor, pool)
try:
while True:
while self.alive:
self.notify()
if self.ppid != os.getppid():
@ -47,6 +47,7 @@ class GEventWorker(AsyncWorker):
pool.join(timeout=self.timeout)
except KeyboardInterrupt:
pass
os._exit(3)
def acceptor(self, pool):
gevent.getcurrent()