def flush():
    """Try to flush all stdio buffers, both from python and from C."""
    try:
        sys.stdout.flush()
        sys.stderr.flush()
    except (AttributeError, ValueError, OSError):
        pass  # unsupported
    try:
        libc.fflush(None)
    except (AttributeError, ValueError, OSError):
        pass  # unsupported
Try to flush all stdio buffers, both from python and from C.
sacred/stdout_capturing.py