mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
wsgi.multiprocess depends on number of workers.
This commit is contained in:
parent
2f06305ce4
commit
9bc19c2c86
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user