简体   繁体   English

释放cgi.FieldStorage临时文件使用的磁盘空间

[英]Release disk space used by cgi.FieldStorage temp files

I am writing a pyramid application that accepts many large file uploads (as a POST ). 我正在编写一个金字塔应用程序,它接受许多大文件上传(作为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. 类似于如何从Python Pyramid中提供临时文件 ,我遇到的问题是cgi.FieldStorage创建的临时文件是孤立的,占用GB的磁盘空间。 lsof indicates that my wsgi process has deleted files from /tmp but the files haven't been closed. lsof表示我的wsgi进程已从/tmp删除了文件,但文件尚未关闭。 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? 如何关闭这些文件以便将磁盘空间返回给操作系统?

This problem I encountered was unrelated to cgi.FieldStorage, pyramid actually uses WebOb for serializing data. 我遇到的这个问题与cgi.FieldStorage无关,金字塔实际上使用WebOb来序列化数据。

The cause of the high disk space usage was pyramid_debugtoolbar . 磁盘空间使用率高的原因是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. 调试器在其文档中声明它保留了前100个请求中的数据,这在我的情况下占用了大量的内存和磁盘空间。 Removing the include for the debugger from __init__.py and restarting the server resolved the problem. __init__.py删除调试器的include并重新启动服务器解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM