开发者

write the uploaded files on the disk

look at this page of web.py: http://webpy.org/cookbook/storeupload/ pay attention to how it write the file on the disk.

The current situation is: I launched a ser开发者_如何学Cver in virtualbox with 256 mb memory and 512 swap. Just when I upload a file larger than 200 mb I get an error("the page is not available temporary").

I think that the python file-write function reads the whole file into the memory, then it crashed due to the limited memory.

Am I right? If so, is there any solution?

Thank you for your time.


Try not to read the whole file in memory, create a loop and transfer the file by 1024 bytes chunks.


I take it you have set up nginx correctly, especially the client_max_body_size directive.

I think you're right, your problem is linked to bad memory usage : it probably comes from the read() method.

Used without a size argument, the entire contents of the file will be read and returned. Since the file is almost as large as the machine's memory, the program's running out of it and crashes.

What you should do is investigate on better ways to copy a file in Python.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜