"Premature end of script headers: wsgihandler.py" on usage of BytesIO()

Discussion in 'Python' started by Yasir Saleem, Nov 19, 2012.

  1. Yasir Saleem

    Yasir Saleem Guest

    Hi all,

    I am generating graphs using "cairo plot" in web2py project. Here I am using BytesIO() stream for generating graphs. Everything runs fine when I run on localhost but when I deploy it on apache server and then run from different machines OR from different browsers in same machine then the server becomes halt and in apache error log, I found this error message:
    Premature end of script headers: wsgihandler.py,

    Furthermore, it occurs only when I use BytesIO() stream for generating graphs. In all other cases, it run smoothly.

    Please guide me that how I should resolve this issue. Furthermore, please also guide, if I can use any stream other BytesIO()
     
    Yasir Saleem, Nov 19, 2012
    #1
    1. Advertising

  2. Yasir Saleem

    Hans Mulder Guest

    Re: "Premature end of script headers: wsgihandler.py" on usage ofBytesIO()

    On 19/11/12 14:29:13, Yasir Saleem wrote:
    > Hi all,
    >
    > I am generating graphs using "cairo plot" in web2py project.
    > Here I am using BytesIO() stream for generating graphs.
    > Everything runs fine when I run on localhost but when I deploy
    > it on apache server and then run from different machines OR
    > from different browsers in same machine then the server
    > becomes halt and in apache error log, I found this error
    > message:
    >
    > Premature end of script headers: wsgihandler.py,
    >
    > Furthermore, it occurs only when I use BytesIO() stream for
    > generating graphs. In all other cases, it run smoothly.
    >
    > Please guide me that how I should resolve this issue.


    One technique is to put at the very top of the script, even
    above the import statements:

    print "Content-Type: text/plain\n\n"

    This will cause all text output by your script to be displayed
    in your browser as plain text [1]. If you inspect it, you'll
    probably find some kind of warning displayed above the HTML
    headers. You'll need to find a way to not receive that warning.

    It's usually best if you can actually solve the issue Python is
    warning about. it that's not possible, suppressing the warning
    may be your only alternative.

    If you can't figure out what the message means, and Google
    doesn't know either, you can post it in this forum and ask
    for further guidance.

    [1] Except if you use Internet Explorer, which will ask you
    whether you want to save the document. You can either do that
    and view the content with another application, or use another
    browser, or change the content-type to text/html. If you do
    the latter, IE will notice that the content is really plain
    text, and that it is actually quite capable of displaying that.


    Hope this helps,

    -- HansM
     
    Hans Mulder, Nov 19, 2012
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. metfan
    Replies:
    2
    Views:
    4,855
    Robert Olofsson
    Oct 21, 2003
  2. Colin J. Williams

    Webchecker Usage - a problem with local usage

    Colin J. Williams, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    545
    Colin J. Williams
    Feb 26, 2004
  3. hvt
    Replies:
    0
    Views:
    1,215
  4. hvt
    Replies:
    0
    Views:
    1,487
  5. Fabian von Romberg

    io.BytesIO

    Fabian von Romberg, Mar 25, 2013, in forum: Python
    Replies:
    4
    Views:
    120
    Fabian von Romberg
    Mar 26, 2013
Loading...

Share This Page