[Twisted-Python] Twisted.logger on windows max recursion depth exceeded
Glyph
glyph at twistedmatrix.com
Sun Jan 7 00:27:54 MST 2018
Hi John,
Lots of interest in logging this week for some reason :-).
> On Jan 6, 2018, at 4:38 AM, John Aherne <johnaherne at rocs.co.uk <mailto:johnaherne at rocs.co.uk>> wrote:
>
> If I comment out the print statements all seems to work correctly.
>
> I assume I am doing something wrong or something I should not be trying to do. But I can't work out what causes the 2 setups to behave so differently.
The issue here is that klein.run() is initializing the (old-style) logging system; that initialization, among other things, includes replacing sys.stdout and sys.stderr with files that will emit log messages rather than write directly.
`print` debugging of log observers is therefore always somewhat risky since many ways of initializing the logging system will do this.
Perhaps the logging system should be a bit more defensive about observers emitting messages; however, for the time being, if you want to do `print` debugging of a log observer, at the top of your file do something like
from sys import stderr as DEBUG
and then everywhere you have a call to the 'print' function, use the 'file' kwarg:
print('ITEM', event[item], file=DEBUG)
I hope this is helpful,
-g
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20180106/0ba90647/attachment-0002.html>
More information about the Twisted-Python
mailing list