Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Problem with cherrypy.session and serve_download
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Zap  
View profile  
 More options May 5, 2:48 am
From: Zap <z...@lancraft.net>
Date: Mon, 4 May 2009 23:48:05 -0700 (PDT)
Local: Tues, May 5 2009 2:48 am
Subject: Problem with cherrypy.session and serve_download
Hello great cherrypy community :)

In the past I ran into the problem that session handling and the
method serve_download() doesn't work well
together. The download of files bigger 100 MB results in an empty file
downloaded by the browser.
I got no error, neither in the cherrypy-log nor on the browser side.
Just this empty file saved on the harddisk.

This small test script should whow this behaviour: (note: you need a
big file to serve)

import os
import cherrypy
from cherrypy.lib.static import serve_download

THIS_DIR = os.path.abspath(os.path.dirname(__file__))

class HelloWorld(object):
    _cp_config = {"tools.sessions.on": True}
    #_cp_config = {} # uncomment this and download will work fine
    def index(self):
        try:
            cherrypy.session["hello"] = "hello"
        except:
            pass
        return serve_download(os.path.join(THIS_DIR, "bigfile.bin"))
    index.exposed = True
cherrypy.config.update({'server.socket_host': '0.0.0.0',
                        'server.socket_port': 8080,
                       })
cherrypy.quickstart(HelloWorld())

Is this a known issue or a limitation we have to live with?

My workaround makes a HTTPRedirect to a download method which is not
part of an object with session handling activated. This seems to work
in general but some clients told me they still download files with a
size of zero bytes sometimes. After some retries the download will
work right but it seems to be some kind of unstable.
Do you have any experience with this unstable behaviours, too?

Best regards,
Zap


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dirk Rothe  
View profile  
 More options May 6, 1:03 am
From: Dirk Rothe <thec...@gmail.com>
Date: Tue, 5 May 2009 22:03:44 -0700 (PDT)
Local: Wed, May 6 2009 1:03 am
Subject: Re: Problem with cherrypy.session and serve_download
I was hit by a similar phenomenon  on a Windows box as described here:
http://www.cherrypy.org/ticket/909

--dirk


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zap  
View profile  
 More options May 7, 12:03 am
From: Zap <z...@lancraft.net>
Date: Wed, 6 May 2009 21:03:11 -0700 (PDT)
Local: Thurs, May 7 2009 12:03 am
Subject: Re: Problem with cherrypy.session and serve_download
I've checked dirks example from http://www.cherrypy.org/ticket/909
and with a size of 128 MB the download via string failed (With 127 MB
it still works).
That is reproducable on my system (Windows XP SP3, Python2.5,
CherryPy3.1.2)
The download via file failed after some retries and occured on a size
of 200 MB.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Zap  
View profile  
 More options Jun 18, 1:09 am
From: Zap <sebastiandani...@gmx.de>
Date: Wed, 17 Jun 2009 22:09:54 -0700 (PDT)
Local: Thurs, Jun 18 2009 1:09 am
Subject: Re: Problem with cherrypy.session and serve_download
I did a monkey patch in my script for the issue described in ticket
#909

Perhaps you're interested to assume the procedure in the cherrypy
sources.
Fact is, I could reproduce the bug on different pc's running
WindowXP
and this workaround helps so far.

import socket
from cherrypy.wsgiserver import CP_fileobject

CP_fileobject_sendall = CP_fileobject.sendall
def _sendall(self, data):
    """ Monkeypatch for cherrypy ticket #909 """
    try:
        CP_fileobject_sendall(self, data)
    except socket.error, e:
        if e.args[0] == 10055:
            # 10055 -> "No buffer space available"
            # try to send the data in smaller parts
            block = 1024 ** 2 # 1 MB
            for pos in xrange(0, len(data), block):
                CP_fileobject_sendall(self, data[pos:pos+block])
        else:
            raise
CP_fileobject.sendall = _sendall

Zap

On 7 Mai, 06:03, Zap <z...@lancraft.net> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google