Re: Keeping logger from snatching stdout?

Jeff Grimmett <[email protected]>
Newsgroups gmane.comp.python.twisted
Message-ID <CA+1iZEfra=hgZaqDXfmfJBGKDvdiK2K2_-7vtd9MSm0ffx4nLg@mail.gmail.com>
Hi, Glyph,

On Wed, Sep 5, 2018 at 3:27 AM Glyph <[email protected]> wrote:

>
>
> On Aug 29, 2018, at 3:48 PM, Jeff Grimmett <[email protected]> wrote:
>
> Why would you do this rather than simply handle logging events? Both
> twisted and the stdlib have mechanisms for adding observers that will give
> you access to more structured information - particularly useful if you are
> trying to display something in a GUI.
>

That's a little more blam than this little script really needs, though I
appreciate the suggestion.


> I brought flask-twisted in local to my code so I could monkey around with
> it. First thing I noticed was that it was using twisted.python.log. I
> messed around with that - commented it out, and now I get no stdout output
> at all.  Set the parameter setStdout to False, same thing.
>
>
> So, this is the old, legacy API, and what you want to use is this:
> https://twistedmatrix.com/documents/current/api/twisted.logger.LogBeginner.beginLoggingTo.html
>

Yeah. Also noted when I saw it. Again, seemed to be more effort than I
wanted, though if someone were to say "well, that's what you're stuck with
if you use that legacy stuff" I'd be off to do the thing.


> I'm very curious what is going on here, and whether it's a logging system
> bug.  Could you whittle this down to a minimal reproducer?
>

The sad part is that when I went to put together  the minimal reproducer,
the problem went away.

There is something in my code somewhere that is causing this. I have no
idea what it is, yet, but when I put together a minimal web server that
uses twisted.reactor.callLater() to periodically start a background task,
Twisted is not grabbing stdout or even pushing its own logging to sdtout.

I think it might be how I set up the original project in my IDE - for the
sample project, I started with a clean directory and clean project file
(PyCharm if it matters). So I'm gonna pursue that further.  I think that it
might be the IDE's environment if you tell it "this is a Flask project". I
was seeing weird things from the minimal example as well until I cleared
out all the IDE meta files and reinitiated it as a "pure Python" (in
PyCharm terms) project.

Thanks for your time and thanks for the push that got me moving (hopefully)
in the right direction. :)

 Regards,

Jeff

_______________________________________________
Twisted-Python mailing list
[email protected]
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.