MCPcopy
hub / github.com/pallets/click / PacifyFlushWrapper

Class PacifyFlushWrapper

src/click/utils.py:522–546  ·  view source on GitHub ↗

This wrapper is used to catch and suppress BrokenPipeErrors resulting from ``.flush()`` being called on broken pipe during the shutdown/final-GC of the Python interpreter. Notably ``.flush()`` is always called on ``sys.stdout`` and ``sys.stderr``. So as to have minimal impact on any

Source from the content-addressed store, hash-verified

520
521
522class PacifyFlushWrapper:
523 """This wrapper is used to catch and suppress BrokenPipeErrors resulting
524 from ``.flush()`` being called on broken pipe during the shutdown/final-GC
525 of the Python interpreter. Notably ``.flush()`` is always called on
526 ``sys.stdout`` and ``sys.stderr``. So as to have minimal impact on any
527 other cleanup code, and the case where the underlying file is not a broken
528 pipe, all calls and attributes are proxied.
529 """
530
531 wrapped: t.IO[t.Any]
532
533 def __init__(self, wrapped: t.IO[t.Any]) -> None:
534 self.wrapped = wrapped
535
536 def flush(self) -> None:
537 try:
538 self.wrapped.flush()
539 except OSError as e:
540 import errno
541
542 if e.errno != errno.EPIPE:
543 raise
544
545 def __getattr__(self, attr: str) -> t.Any:
546 return getattr(self.wrapped, attr)
547
548
549def _detect_program_name(

Callers 1

mainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…