mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #1088 from benoitc/fix/905
don't close the unix socket when the worker exit
This commit is contained in:
commit
89562c776e
@ -57,7 +57,6 @@ class BaseSocket(object):
|
|||||||
self.sock.close()
|
self.sock.close()
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
self.log.info("Error while closing socket %s", str(e))
|
self.log.info("Error while closing socket %s", str(e))
|
||||||
time.sleep(0.3)
|
|
||||||
del self.sock
|
del self.sock
|
||||||
|
|
||||||
|
|
||||||
@ -104,6 +103,7 @@ class UnixSocket(BaseSocket):
|
|||||||
os.remove(addr)
|
os.remove(addr)
|
||||||
else:
|
else:
|
||||||
raise ValueError("%r is not a socket" % addr)
|
raise ValueError("%r is not a socket" % addr)
|
||||||
|
self.parent = os.getpid()
|
||||||
super(UnixSocket, self).__init__(addr, conf, log, fd=fd)
|
super(UnixSocket, self).__init__(addr, conf, log, fd=fd)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -118,7 +118,8 @@ class UnixSocket(BaseSocket):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
super(UnixSocket, self).close()
|
super(UnixSocket, self).close()
|
||||||
os.unlink(self.cfg_addr)
|
if self.parent == os.getpid():
|
||||||
|
os.unlink(self.cfg_addr)
|
||||||
|
|
||||||
|
|
||||||
def _sock_type(addr):
|
def _sock_type(addr):
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import greenlet
|
|||||||
from gunicorn.http.wsgi import sendfile as o_sendfile
|
from gunicorn.http.wsgi import sendfile as o_sendfile
|
||||||
from gunicorn.workers.async import AsyncWorker
|
from gunicorn.workers.async import AsyncWorker
|
||||||
|
|
||||||
|
|
||||||
def _eventlet_sendfile(fdout, fdin, offset, nbytes):
|
def _eventlet_sendfile(fdout, fdin, offset, nbytes):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@ -87,11 +86,11 @@ def patch_sendfile():
|
|||||||
class EventletWorker(AsyncWorker):
|
class EventletWorker(AsyncWorker):
|
||||||
|
|
||||||
def patch(self):
|
def patch(self):
|
||||||
|
hubs.use_hub()
|
||||||
eventlet.monkey_patch(os=False)
|
eventlet.monkey_patch(os=False)
|
||||||
patch_sendfile()
|
patch_sendfile()
|
||||||
|
|
||||||
def init_process(self):
|
def init_process(self):
|
||||||
hubs.use_hub()
|
|
||||||
self.patch()
|
self.patch()
|
||||||
super(EventletWorker, self).init_process()
|
super(EventletWorker, self).init_process()
|
||||||
|
|
||||||
@ -119,7 +118,11 @@ class EventletWorker(AsyncWorker):
|
|||||||
|
|
||||||
while self.alive:
|
while self.alive:
|
||||||
self.notify()
|
self.notify()
|
||||||
eventlet.sleep(1.0)
|
try:
|
||||||
|
eventlet.sleep(1.0)
|
||||||
|
except AssertionError:
|
||||||
|
self.alive = False
|
||||||
|
break
|
||||||
|
|
||||||
self.notify()
|
self.notify()
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user