-
Notifications
You must be signed in to change notification settings - Fork 144
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
[launch] not wiring python prints to stdout in realtime #188
Comments
I think the difference is that we intentionally flush the out when logging: https://github.com/ros2/rcutils/blob/a7581a333444c2804f2b7c27dd0da1b2946bebff/src/logging.c#L702 There is inherent buffing of stdout when a process is not connected to a tty. If you changed this: import launch
import launch_ros.actions
def generate_launch_description():
launch_description = launch.LaunchDescription()
launch_description.add_action(
launch_ros.actions.Node(
package='demo_nodes_cpp', node_executable='talker', output='screen'),
)
launch_description.add_action(
launch_ros.actions.Node(
package='demo_nodes_py', node_executable='talker', output='screen',
env={PYTHONUNBUFFERED : "1"}),
)
return launch_description I expect that you'll see prompt printing. It's possible that the
|
osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py#L67-L68 so that keyword arguments are utilised (otherwise you'll get positional argument errors):
Are there consequences of |
That all being said, I think it's worth turning on by default and exposing a launch/launch/launch/actions/execute_process.py Lines 162 to 164 in e870424
In that case you can either specify a prefix manually for a single invocation of |
@mjcarroll you're pointing to a very old PR (2017). Was that intended? I've got the bugfix PR in that enables the solution proposed by @wjwwood to be attempted but haven't had the cycles to contribute that PR yet. |
Rename nodes apart to work around rclcpp bug ros2/launch#204
I'm not totally sure but is this the same issue that's causing us to not see any stdout output at all while the node is running? (https://answers.ros.org/question/332829/no-stdout-logging-output-in-ros2-using-launch/) If so this seems like a serious problem that needs to be escalated. |
Unfortunately, this setting is not on by default yet, as it causes all kinds of other issues, but you can enable it yourself and probably fix the problem. If using |
This is the pr which is stalled at the moment because I don't have time to pursue it which enables We should address all the issues that cause this, but honestly even if we could enable it by default, I'm worried about the performance in a large system. As was the conclusion in other threads, e.g. ros2/rcutils#169 (comment), we may want to leave this off by default or use some heuristic like: only turning it on if |
@wjwwood, that's the wrong fix. User-readable debug output should go to stderr. If you're worried about performance, that's what log_level is for |
Which fix? I don't think I said debug output shouldn't go to stderr. Of course you can do things to fix performance on the application side (print less or adjust the log level), but there's no reason for launch to log stdout/stderr to file with line buffering instead of full buffering... |
Sorry, nevermind. I thought you were aiming to fix the similar issue ros2/rcutils#168. |
No, that probably needs to change as you guys have advocated. Just don't have time to push on it atm. |
Confirmed that enabling |
@fabrizioromanelli I understood how the launch system works: by default, stdout is redirected to a log file and only stderr is shown on screen. This is to address by default systems where everything runs headlessly. However, this behaviour can be changed with the two options I added. Now we should see everything ORB_SLAM2 does in the console and launch log file as well. I/O buffering is disabled in orbslam2_ros2.cpp::main so everything happens asap. If you have a couple of mins please try and check if this doesn't generate too many prints but a nice console log. Refs are: - https://answers.ros.org/question/332829/no-stdout-logging-output-in-ros2-using-launch/ - ros2/launch#188 - Python ROS 2 source code for ExecuteProcess class and launch.logging module
@fabrizioromanelli I understood how the launch system works: by default, stdout is redirected to a log file and only stderr is shown on screen. This is to address by default systems where everything runs headlessly. However, this behaviour can be changed with the two options I added. Now we should see everything ORB_SLAM2 does in the console and launch log file as well. I/O buffering is disabled in orbslam2_ros2.cpp::main so everything happens asap. If you have a couple of mins please try and check if this doesn't generate too many prints but a nice console log. Refs are: - https://answers.ros.org/question/332829/no-stdout-logging-output-in-ros2-using-launch/ - ros2/launch#188 - Python ROS 2 source code for ExecuteProcess class and launch.logging module
Solution given the above discussion:
|
Bug report
Required Info:
Steps to reproduce issue
cout
equivalent of the logged message in demo_nodes_cpp/src/topics/talker.cppprint
equivalent of the logged message in demo_nodes_py/demo_nodes_py/talker.pyAdd them both to a launcher:
and call
ros2 launch ...
on it.Expected behavior
Both logged messages and cout/print messages make it in realtime to stdout.
Actual behavior
All make it there except the python
print
statements. They only show on stdout after interrupting the launch with CTRL-C.The text was updated successfully, but these errors were encountered: