Search code examples
linuxpyramidwsgi

Release disk space used by cgi.FieldStorage temp files


I am writing a pyramid application that accepts many large file uploads (as a POST). Similar to How can I serve temporary files from Python Pyramid, I'm having a problem where the the temp files created by cgi.FieldStorage are orphaned, consuming GB's of disk space. lsof indicates that my wsgi process has deleted files from /tmp but the files haven't been closed. Restarting the application clears the orphans.

How can I cause these files to be closed so that the disk space is returned to the OS?


Solution

  • This problem I encountered was unrelated to cgi.FieldStorage, pyramid actually uses WebOb for serializing data.

    The cause of the high disk space usage was pyramid_debugtoolbar. The debugger states in it's documentation that it maintains the data from the previous 100 requests, which took up a great amount of memory and disk space in my case. Removing the include for the debugger from __init__.py and restarting the server resolved the problem.