I think you would be happier if you let Apache handle this. It's very
good at that kind of thing. You really need to do some low-level I/O
performance tweaks in order to stream multigigabyte files, and you can't
do that in Python.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.
def upload(self, myFile):
out = """<html>
<body>
myFile length: %s<br />
myFile filename: %s<br />
myFile mime-type: %s
</body>
</html>"""
# Although this just counts the file length, it demonstrates
# how to read large files in chunks instead of all at once.
# CherryPy reads the uploaded file into a temporary file;
# myFile.file.read reads from that.
size = 0
while True:
data = myFile.file.read(8192)
if not data:
break
size += len(data)
return out % (size, myFile.filename, myFile.content_type)
upload.exposed = True
(taken from - http://docs.cherrypy.org/dev/progguide/files/uploading.html)
If that's not good enough - you can specify custom request body
processors to read the file in chunks and directly write it to where
you want it to go (although you should probably validate it before
doing this) - http://www.cherrypy.org/wiki/RequestBodies
Lakin
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To post to this group, send email to cherryp...@googlegroups.com.
> To unsubscribe from this group, send email to
> cherrypy-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cherrypy-users?hl=en.
>
>
Lakin
Lakin
On Wed, Jul 6, 2011 at 9:34 PM, Lakin Wecker
> I am working on a personal project programming a video library.
> However I ran into a big problem, when I try to server my videos up
> (mp4s) my ram maxs out and my IO sky rockets. Its only running on a
> netbook so it does not even finish serving. The files are from 500MB
> to 6GB.
May I suggest a change in your application/environment architecture? I
too made a site which provided streaming of large video files to
visitors. I hosted all the big content on Amazon S3, and had CloudFront
serve it. The webapp only serves small pages containing links to these
CloudFront-hosted videos.
The serving of static content, especially large files, is better not
placed as a burden on CherryPy (or Django, or Rails, for that matter).
Instead, use something as nginx to do that (this will also take care of
not blocking your webapp when many slow clients connect).
Greetings,
--
"Good programming is not learned from generalities, but by seeing how
significant programs can be made clean, easy to read, easy to maintain
and modify, human-engineered, efficient, and reliable, by the application
of common sense and good programming practices. Careful study and
imitation of good programs leads to better writing."
- Kernighan and Plauger, motto of 'Software Tools'