Revert "fix issue #348 ."

This reverts commit da637dfd13b520fc190b86967dfecc06bf97a2b4.
This commit is contained in:
benoitc 2012-06-19 10:31:06 +02:00
parent 512650d582
commit 12a0e55bcf
4 changed files with 2 additions and 35 deletions

View File

@ -1,22 +0,0 @@
from multiprocessing import Process, Queue
import requests
def child_process(queue):
while True:
print queue.get()
r = requests.get('http://friendpaste.com')
print r.headers
class GunicornSubProcessTestMiddleware(object):
def __init__(self):
super(GunicornSubProcessTestMiddleware, self).__init__()
self.queue = Queue()
self.process = Process(target=child_process, args=(self.queue,))
self.process.start()
def process_request(self, request):
self.queue.put(('REQUEST',))
def process_response(self, request, response):
self.queue.put(('RESPONSE',response.status_code))
return response

View File

@ -98,7 +98,6 @@ MIDDLEWARE_CLASSES = (
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'testing.apps.someapp.middleware.GunicornSubProcessTestMiddleware'
)
ROOT_URLCONF = 'testing.urls'

View File

@ -353,10 +353,3 @@ def check_is_writeable(path):
except IOError, e:
raise RuntimeError("Error: '%s' isn't writable [%r]" % (path, e))
f.close()
def is_process_running(process_id):
try:
os.kill(process_id, 0)
return True
except OSError:
return False

View File

@ -23,7 +23,6 @@ from gevent import pywsgi
import gunicorn
from gunicorn.workers.async import AsyncWorker
from gunicorn.util import is_process_running
VERSION = "gevent/%s gunicorn/%s" % (gevent.__version__, gunicorn.__version__)
@ -37,7 +36,6 @@ BASE_WSGI_ENV = {
'wsgi.run_once': False
}
class GeventWorker(AsyncWorker):
server_class = None
@ -63,12 +61,11 @@ class GeventWorker(AsyncWorker):
else:
server = StreamServer(self.socket, handle=self.handle, spawn=pool)
gevent.spawn(server.start)
server.start()
try:
while self.alive:
self.notify()
if not is_process_running(self.ppid):
if self.ppid != os.getppid():
self.log.info("Parent changed, shutting down: %s", self)
break