cherrypy.request.body question

209 views
Skip to first unread message

jbastos

unread,
Jul 6, 2012, 5:18:55 PM7/6/12
to cherryp...@googlegroups.com

Greetings,


the code below is a dummy decorator. I plan to upload large files, and I'm worried about memory consumption,

My question is: if the content-length is big, say, greater than 1 Megabyte, where does  cherrypy.request.body.read reads from?


- from a memory object?

- from the socket?

- from a temporary file?


def dummy(fn):

    def _dummy(self, *args, **params):

        cl = cherrypy.request.headers['Content-Length']

        rawbody = cherrypy.request.body.read(int(cl))

        return fn(self,*args,**params)

    return _dummy


Regards,

Jose

Alan Pound

unread,
Jul 6, 2012, 6:15:55 PM7/6/12
to cherryp...@googlegroups.com

http://docs.cherrypy.org/stable/progguide/files/uploading.html

The first line says: "When a client uploads a file to a CherryPy application, it’s placed on disk immediately."

On a separate point - you should be aware that if you try uploads under HTTPS, CP is broken, and has been for ages. I documented it here: https://groups.google.com/forum/?fromgroups#!topic/cherrypy-users/6y3pPbPQ5Oo and I also noted a nasty crufty (but 100% effective) fix.

The same problem had already been logged as Issue #954, and I've just this moment spotted this: https://bitbucket.org/cherrypy/cherrypy/issue/1068/file-upload-crashes-when-using-https which looks like exactly the same problem, with a very similar fix to my own.

CP has another issue, a design issue, that means that it's HTTPS setup is unusably slow when there are a lot of requests...

However! Nil desperandum (or whatever) I would *very strongly suggest* that for production you avoid these problems altogether, and do what everybody else seems to be doing, and run CP behind Nginx (which is probably why no-one is rushing to fix these issues).

Nginx is rock-solid, simple to setup and use, fast, will take over the HTTPS stuf, passing the traffic back to CP as HTTP, which is fast, you can run multiple, python/CP instances behind Nginx for capacity (hint - without jumping through hoops, a single python instance will only use a single core on your server) and resilience (if you do it right).

I hope this helps

(PS Myself, I'm pretty happy with Cherrypy - it will probably do just about everything you will ever want of it - the only challenge is figuring out how to do it - the documentation doesn't really cover everything you will want to understand...)

I hope this helps...

Alan
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cherrypy-users/-/432BmSekWNgJ.
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.




winmail.dat
Reply all
Reply to author
Forward
0 new messages