[Twisted-Python] Log falls over due to recursion

Steve Freitas sflist at ihonk.com
Mon Feb 5 06:18:05 EST 2007

Submitted as evidence that I'm not as good at thinking through the
consequences of my actions as I'd like. Embarrassingly so. Enjoy.

I'd like to send log events to a log server via xmlrpc. So I created an
object with write() and flush() functions, and passed it to
t.p.log.FileLogObserver. In write(), I intended to use
t.w.xmlrpc.Proxy.callRemote() to send the log entry someplace. However,
this creates some log messages of its own as the xmlrpc._QueryFactory
starts up and shuts down. These trigger my observer, of course, which
tries to send 'em out over Proxy.callRemote() again, and pretty soon I'm
leaping out of my chair trying to dodge melted drive screws and paper
coin roll wrappers on various ballistic trajectories. (Well, they were
sitting on my computer. Never mind.)

I tried using FileLogObserver.stop() right before the xmlrpc call and
using start() after the call completes. It didn't work, but even if it
did, it would be a poor solution, since it would miss any log events
occurring during that time.

So I guess I need to somehow divert the log output of the consequences
of my particular call (Proxy.callRemote()) to another sink, all the
while leaving the rest of the logging functioning normally. Any
semi-reasonable way to do that?


More information about the Twisted-Python mailing list