SimpleXMLRPCServer clobbering sys.stderr? (2.5.2)

J

Joseph Turian

I was having a mysterious problem with SimpleXMLRPCServer. (I am using
Python 2.5.2)
The request handlers were sometimes failing without any error message
to the log output.

What I discovered was perplexing.
I had some 'print' statements in the handers that, assuming the
request would be handled, would print just fine. When I switched to
'print >> sys.stderr', the request handlers would just fail
completely, and not make the sys.stderr output that I desired.

It seems that SimpleXMLRPCServer is clobbering stderr in some bizarre
and silent-error-causing way.
I can't really find any documentation of explanation of this
phenomenon.

Could someone please illuminate it for me?

Best,
Joseph
 
J

Joseph Turian

I was having a mysterious problem with SimpleXMLRPCServer. (I am using
I'd start updating Python to the latest 2.5 release: 2.5.4

Ubuntu doesn't have 2.5.4. :(
Perhaps you need to flush the file also? sys.stderr.flush()

Flushing will not help, because it will be too late.
It is almost like when I write to sys.stderr, the XMLRPC connection
just hangs up or something like that.
XMLRPCServer doesn't reassign or alter sys.stderr, just uses it in the
log_message method. I'd look in some other place...

Here's what I see:
* If I use logging to write the output, I don't see any output in the
server log, but the client gets correct results.
* If I use sys.stderr to write the output, I don't see any output in
the server log AND the client gets INcorrect results.
* If I use sys.stdout to write the output, I DO see any output in the
server log AND the client gets correct results.

Why does only sys.stdout work within XMLRPCServer registered methods?

Thanks,
Joseph
 
J

Joseph Turian

Here's what I see:
* If I use logging to write the output, I don't see any output in the
server log, but the client gets correct results.
* If I use sys.stderrto write the output, I don't see any output in
the server log AND the client gets INcorrect results.
* If I use sys.stdout to write the output, I DO see any output in the
server log AND the client gets correct results.

Oh, one more thing.

If I write sys.stdout and then issue:
sys.stdout.flush()
It appears that the handler aborts at that point and gets no further
into the method.
Why would this happen?

Thanks,
Joseph
 
G

Gabriel Genellina

Here's what I see:
* If I use logging to write the output, I don't see any output in the
server log, but the client gets correct results.
* If I use sys.stderr to write the output, I don't see any output in
the server log AND the client gets INcorrect results.
* If I use sys.stdout to write the output, I DO see any output in the
server log AND the client gets correct results.

Why does only sys.stdout work within XMLRPCServer registered methods?

I'm afraid I'm out of ideas. Inside SimpleXMLRPCServer.py there is no
reference to 'stderr', and stdout only appears in the CGI handler.
BaseHTTPServer.py writes to sys.stderr in log_message(). SocketServer.py
may write to both sys.stderr and sys.stdout when an error is encountered
(in the handle_error method). But none of them alters nor reassigns
sys.stdout/sys.stderr; all output should go to the console from which you
started the server, unless you redirect it from the command line (or your
main program redirects it by code or does something strange with those
handles)
 
B

Brian Quinlan

Do you have some code that we could see that provokes the problem?

Cheers,
Brian
 

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,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top