SimpleXMLRPCServer clobbering sys.stderr? (2.5.2)

Joseph Turian turian at gmail.com
Sun Oct 18 23:09:10 EDT 2009


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

Ubuntu doesn't have 2.5.4. :(

> > 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.stderroutput that I desired.
>
> 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



More information about the Python-list mailing list