Hi,
I've managed to make a minimal wsgi application that shows off a
problem we encountered in production. It looks like mod_wsgi is
leaking the temporary files we give to it. Perhaps we are doing
something wrong, but I couldn't find any docs against passing
tempfile.mkstemp files to mod_wsgi. Curiously, creating the file with
tempfile.TemporaryFile rather than tempfile.mkstemp has allowed us to
work around the issue.
Basically running ab against this application:
#!/usr/bin/python
import tempfile
import os
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
# Make a temporary file and write data to it
_, filename = tempfile.mkstemp()
f = open(filename, 'wb')
f.write(output)
f.close()
# Make a deleted read-only file to pass to mod_wsgi
readf = open(filename, 'rb')
os.remove(filename)
wrapper = environ.get('wsgi.file_wrapper')
return wrapper(readf)
Causes these errors:
[Fri Mar 06 09:50:16 2009] [error] [client 62.57.1.12] mod_wsgi
(pid=18665): Exception occurred processing WSGI script '/etc/apache2/
wsgi/wsgitest.wsgi'.
[Fri Mar 06 09:50:16 2009] [error] Traceback (most recent call last):
[Fri Mar 06 09:50:16 2009] [error] File "/etc/apache2/wsgi/
wsgitest.wsgi", line 15, in application
[Fri Mar 06 09:50:16 2009] [error] File "tempfile.py", line 302, in
mkstemp
[Fri Mar 06 09:50:16 2009] [error] File "tempfile.py", line 236, in
_mkstemp_inner
[Fri Mar 06 09:50:16 2009] [error] OSError: [Errno 24] Too many open
files: '/tmp/tmp3zONgs'
Because you very quickly get to the per-process file limit:
load:/etc/apache2/wsgi# ls /proc/18665/fd | wc -l
1023
We're running python 2.4.4, apache 2.2.3-4+etch6 on Debian Etch and
have seen this with mod_wsgi 2.1 and 2.3.
Many Thanks,
Brian
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---