MCPcopy
hub / github.com/Textualize/rich / on_broken_pipe

Method on_broken_pipe

rich/console.py:2030–2042  ·  view source on GitHub ↗

This function is called when a `BrokenPipeError` is raised. This can occur when piping Textual output in Linux and macOS. The default implementation is to exit the app, but you could implement this method in a subclass to change the behavior. See https://docs.python

(self)

Source from the content-addressed store, hash-verified

2028 buffer_extend(line)
2029
2030 def on_broken_pipe(self) -> None:
2031 """This function is called when a `BrokenPipeError` is raised.
2032
2033 This can occur when piping Textual output in Linux and macOS.
2034 The default implementation is to exit the app, but you could implement
2035 this method in a subclass to change the behavior.
2036
2037 See https://docs.python.org/3/library/signal.html#note-on-sigpipe for details.
2038 """
2039 self.quiet = True
2040 devnull = os.open(os.devnull, os.O_WRONLY)
2041 os.dup2(devnull, sys.stdout.fileno())
2042 raise SystemExit(1)
2043
2044 def _check_buffer(self) -> None:
2045 """Check if the buffer may be rendered. Render it if it can (e.g. Console.quiet is False)

Callers 1

_check_bufferMethod · 0.95

Calls 2

openMethod · 0.80
filenoMethod · 0.45

Tested by

no test coverage detected