From 9bc19c2c86f45595ff71d83468742fdf80318592 Mon Sep 17 00:00:00 2001 From: benoitc Date: Tue, 22 Jun 2010 19:24:43 +0200 Subject: [PATCH] wsgi.multiprocess depends on number of workers. --- gunicorn/http/wsgi.py | 11 ++++------- gunicorn/workers/async.py | 3 ++- gunicorn/workers/sync.py | 3 ++- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gunicorn/http/wsgi.py b/gunicorn/http/wsgi.py index 63054597..913ca309 100644 --- a/gunicorn/http/wsgi.py +++ b/gunicorn/http/wsgi.py @@ -17,7 +17,7 @@ NORMALIZE_SPACE = re.compile(r'(?:\r\n)?[ \t]+') log = logging.getLogger(__name__) -def create(req, sock, client, server, debug=False): +def create(req, sock, client, server, cfg): resp = Response(req, sock) environ = {} @@ -54,11 +54,8 @@ def create(req, sock, client, server, debug=False): else: continue - # This value should evaluate true if an equivalent application - # object may be simultaneously invoked by another process, and - # should evaluate false otherwise. In debug mode we fall to one - # worker so we comply to pylons and other paster app. - wsgi_multiprocess = (debug == False) + wsgi_multiprocess = (cfg.workers > 1) + if isinstance(forward, basestring): # we only took the last one @@ -108,7 +105,7 @@ def create(req, sock, client, server, debug=False): key = 'HTTP_' + key.upper().replace('-', '_') if key not in ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'): environ[key] = value - + return resp, environ class Response(object): diff --git a/gunicorn/workers/async.py b/gunicorn/workers/async.py index ffb33298..5d6ac585 100644 --- a/gunicorn/workers/async.py +++ b/gunicorn/workers/async.py @@ -61,7 +61,8 @@ class AsyncWorker(base.Worker): def handle_request(self, req, sock, addr): try: debug = self.cfg.debug or False - resp, environ = wsgi.create(req, sock, addr, self.address, debug) + resp, environ = wsgi.create(req, sock, addr, self.address, + self.cfg) respiter = self.wsgi(environ, resp.start_response) if respiter == ALREADY_HANDLED: return False diff --git a/gunicorn/workers/sync.py b/gunicorn/workers/sync.py index 7c616db7..6fda3b45 100644 --- a/gunicorn/workers/sync.py +++ b/gunicorn/workers/sync.py @@ -92,7 +92,8 @@ class SyncWorker(base.Worker): def handle_request(self, req, client, addr): try: debug = self.cfg.debug or False - resp, environ = wsgi.create(req, client, addr, self.address, debug) + resp, environ = wsgi.create(req, client, addr, + self.address, self.cfg) respiter = self.wsgi(environ, resp.start_response) for item in respiter: resp.write(item)