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

Y

Yasir Saleem

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()
 
H

Hans Mulder

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top