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

Make the ros2cli output always line buffered #659

Merged
merged 4 commits into from
Aug 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ros2cli/ros2cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@
# limitations under the License.

import argparse
import builtins
import functools
import signal

from ros2cli.command import add_subparsers_on_demand


def main(*, script_name='ros2', argv=None, description=None, extension=None):
# Make the output always line buffered, even when piping the output to another process.
# If you explicitly passed `flush=false`, that's not going to be the case.
# This only modifies the behavior of print(), if you write to stdout in another way line
# buffering is not guaranteed.
builtins.print = functools.partial(print, flush=True)

if description is None:
description = f'{script_name} is an extensible command-line tool ' \
'for ROS 2.'
Expand Down