Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pserve should write verbose messages to stderr, not stdout. #3592

Closed
ztane opened this issue Jun 1, 2020 · 3 comments
Closed

pserve should write verbose messages to stderr, not stdout. #3592

ztane opened this issue Jun 1, 2020 · 3 comments

Comments

@ztane
Copy link
Contributor

ztane commented Jun 1, 2020

pserve.py has this method for outputting verbose diagnostics:

    def out(self, msg):  # pragma: no cover
        if self.args.verbose > 0:
            print(msg)

and a couple direct prints.

I was running my code in Docker and thought there was something really wrong with my container as I didn't get the pserve diagnostics messages. Turns out that it was just because stdout was in fully-buffered mode.

Suggestion: change prints to print(..., file=sys.stderr)... then one can see the message in logs before a full block is output to stdout ;)

ztane added a commit to ztane/pyramid that referenced this issue Jun 1, 2020
ztane added a commit to ztane/pyramid that referenced this issue Jun 1, 2020
@mmerickel
Copy link
Member

I’m not super comfortable overriding Python defaults here. It feels like it’ll just hide a deeper config issue in other print statements.

@ztane
Copy link
Contributor Author

ztane commented Jun 1, 2020

@mmerickel I am proposing changing only the few prints in pserve.py, as it is the only place which actually produces logging, and which is hard to monkeypatch. There is only one other place in the Pyramid codebase which semantically should use sys.stderr which would be the usage description in alchemy scaffold, which should go to sys.stderr but then those pedantic can change it themselves.

But the pserve.py prints cannot be changed. The problem is that the stdout of C stdio is supposed to be line or full buffered depending on where it is connected, whereas stderr is unbuffered. The problem with these statements now is that in many cases they show up in logs only when the program is terminated. translogger et all do log into stderr, because those messages show up in my terminal before the messages from pserve (which show only when I terminate the container).

mmerickel added a commit that referenced this issue Jun 3, 2020
Fixing #3592 - output diagnostic messages to stderr, not stdout
@mmerickel
Copy link
Member

fixed via #3593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants