fix issue #25.

This commit is contained in:
benoitc 2010-03-01 16:28:37 +01:00
parent 368257a733
commit d33c5b6c86
5 changed files with 14 additions and 6 deletions

View File

@ -21,6 +21,7 @@ Example gunicorn.conf.py
user = None # Change process owner to user
group = None # Change process group to group
proc_name = None # Change the process name
tmp_upload_dir = None # Set path used to store temporary uploads
def after_fork(server, worker):
fmt = "worker=%s spawned pid=%s"
@ -74,3 +75,6 @@ umask:
user:
The user as which worker processes will by launched.
tmp_upload_dir:
Set the path used to store temporarily the body of the request.

View File

@ -25,6 +25,7 @@ class Config(object):
umask="0",
user=None,
group=None,
tmp_upload_dir=None,
after_fork=lambda server, worker: server.log.info(
"Worker spawned (pid: %s)" % worker.pid),

View File

@ -36,8 +36,9 @@ class Request(object):
"SERVER_SOFTWARE": "gunicorn/%s" % __version__
}
def __init__(self, socket, client_address, server_address, debug=False):
self.debug = debug
def __init__(self, socket, client_address, server_address, conf):
self.debug = conf['debug']
self.conf = conf
self.socket = socket
self.client_address = client_address
@ -73,7 +74,7 @@ class Request(object):
if not self.parser.content_len and not self.parser.is_chunked:
wsgi_input = StringIO.StringIO()
else:
wsgi_input = TeeInput(self.socket, self.parser, buf[i:])
wsgi_input = TeeInput(self.socket, self.parser, buf[i:], self.conf)
# This value should evaluate true if an equivalent application
# object may be simultaneously invoked by another process, and

View File

@ -19,7 +19,8 @@ from gunicorn.util import MAX_BODY, CHUNK_SIZE, read_partial
class TeeInput(object):
def __init__(self, socket, parser, buf):
def __init__(self, socket, parser, buf, conf):
self.conf = conf
self.buf = buf
self.parser = parser
self.socket = socket
@ -28,7 +29,8 @@ class TeeInput(object):
if self._len and self._len < MAX_BODY:
self.tmp = StringIO.StringIO()
else:
self.tmp = tempfile.TemporaryFile()
self.tmp = tempfile.TemporaryFile(
dir=self.conf['tmp_upload_dir'])
if len(buf) > 0:
chunk, self.buf = parser.filter_body(buf)

View File

@ -143,7 +143,7 @@ class Worker(object):
def handle(self, client, addr):
util.close_on_exec(client)
try:
req = http.Request(client, addr, self.address, self.debug)
req = http.Request(client, addr, self.address, self.conf)
try:
response = self.app(req.read(), req.start_response)