INNER CODE UNIT · Python

handle_broken_pipe_error

datachain-ai/datachain · src/datachain/cli/__init__.py:322

def handle_broken_pipe_error(exc):
    # Python flushes standard streams on exit; redirect remaining output
    # to devnull to avoid another BrokenPipeError at shutdown
    # See: https://docs.python.org/3/library/signal.html#note-on-sigpipe
    error = str(exc)
    devnull = os.open(os.devnull, os.O_WRONLY)
    os.dup2(devnull, sys.stdout.fileno())
    return error, 141  # 128 + 13 (SIGPIPE)


def handle_general_exception(exc, args, logging_level):
    error = str(exc)
    if isinstance(exc, KeyboardInterrupt):
        msg = "Operation cancelled by the user"
    else:
        msg = str(exc)
    print("Error:", msg, file=sys.stderr)
    if logging_level <= logging.DEBUG:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…