Missing Output

imkevinxu edited this page Mar 20, 2013 · 13 revisions

If you are not seeing any output from your program, there is a likely chance that it is buffering stdout. Many languages such as Ruby and Python buffer stdout by default. To disable this behavior, add this code as early as possible in your program:


$stdout.sync = true


Set PYTHONUNBUFFERED=True in the environment, or

python -u script.py


Ruby buffers stdout by default. It has an exception to this rule in the presence of a tty (interactive terminal).

Earlier versions of foreman (< 0.29.0) faked being a tty to trick ruby into not buffering. This, however, had unintended consequences. For example, many programs choose to check whether an input terminal is a tty before asking for user input.

Foreman no longer tells its child processes that they have an interactive terminal present. This more accurately represents what will happen in production under something like upstart or god as well. Because of this, you have to tell ruby not to buffer stdout if you want real-time output.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.