-
Notifications
You must be signed in to change notification settings - Fork 148
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
catkin_build: print log if stderr is not empty (linux side only), see #1 #57
Conversation
…atkin#1 If something got printed on stderr by a build command, the user will want to know about it. So gather stderr separately from stdout and check if it is non-empty when the command finishes.
I know that the current solution does not guarantee correct ordering of stdout/stderr messages. gcc knows that stdout/stderr ordering is not guaranteed, and prints the whole context with each error. CMake also prints context ( We could even hide stdout to remove any possibility of confusion and request that the user re-run with What do you think? |
@xqms So my problem with capturing it separately is that we loose ordering between The other problem is that we always capture the data to log files and even if we hide the stdout to the screen the log files should contain all output and in the correct order, IMO. I have put together a new version of this here: The above does not use a pty, there is another one which has the same signature which does use pty: I have taken the time to make up four tests for each function:
In all cases the script run is this: from __future__ import print_function
import sys
print("out 1")
print("err 1", file=sys.stderr)
print("out 2") Now, without a pty, the only case which works is "combined with unbuffered option". To my surprise when using the pty implementation both combined and non-combined produce the same, correctly ordered, output. I was not surprised to learn that the unbuffered option was not required, because that is part of what you would want to use the pty for. So it seems like I can capture separately as long as I use a pty to do it. I am concerned that this will not work for all unix/posix systems and that system load might affect the order. I'm also not sure how this will affect Windows. I am also concerned about requiring the use of pty for correct ordering, because it is possible that we run out of pty's and have to fallback to non-pty. I was ok with this when the consequence was that we no longer captured color data, but now it seems that is will affect output order, which is less desirable. |
Thanks for your detailed analysis! And if we make it clear that correct ordering cannot be guaranteed without I still feel that hiding stderr away is worse than losing order. Do you have an actual situation in mind where stdout/stderr ordering makes a difference to the user? With parallel make ( |
So I think this can be the behavior:
In the typical case we get everything we want, in the extreme case we loose color and stderr/stdout ordering. I think this may be a decent trade-off. |
Sounds good to me! Feel free to close this pull request. I'm assuming you are planning to substitute the whole run_*.py stuff with the osrf_pycommon library anyway, so my patch is obsolete. I just thought of one more thing: You currently use So maybe you could use |
I might look into using epoll, because I will have to have special logic anyways, since select doesn't work with file descriptors on Windows, only sockets... |
Here is an update on this, I have decided to use the new I have implemented this in |
Do you want any help integrating this? |
@jbohren yeah if you are interested in working on it, I imagine it will be a little involved, because I basically intend to refactor all of the job executor into the python An intermediate step would be to replace http://osrf-pycommon.readthedocs.org/en/latest/process_utils.html#synchronous-process-utilities This would be more straight forward to do, but might not be the highest priority problem right now. |
@wjwwood @xqms I've been hacking on this sketch for a new asyncio-based executor (which can also be used for cleaning packages). Take a look and tell me what you think. https://gist.github.com/jbohren/9cd689c08782d6ffbcdf |
@jbohren Thank you for going all the way and implementing it properly ;-) |
As discussed in #1, opening a pull request to make discussion easier. Not ready for merge! This is merely a testbed to see if stdout/stderr interleaving poses an issue.
If something got printed on stderr by a build command, the user will want
to know about it. So gather stderr separately from stdout and check if
it is non-empty when the command finishes.