work around evdns not playing well with fork

This commit is contained in:
Randall Leeds 2010-07-22 14:06:19 -07:00
parent 9f941215d1
commit dbd66b6191

View File

@ -35,7 +35,7 @@ class GeventWorker(AsyncWorker):
@classmethod
def setup(cls):
from gevent import monkey
monkey.patch_all(dns=False)
monkey.patch_all()
def timeout_ctx(self):
return gevent.Timeout(self.cfg.keepalive, False)
@ -59,6 +59,13 @@ class GeventWorker(AsyncWorker):
except KeyboardInterrupt:
pass
def init_process(self):
#gevent doesn't reinitialize dns for us after forking
#here's the workaround
gevent.core.dns_shutdown(fail_requests=1)
gevent.core.dns_init()
super(GeventWorker, self).init_process()
def acceptor(self, pool):
gevent.getcurrent()
while self.alive: