BrokenPipeError

Built-in ExceptionPython 2.0+Intermediate

Raised when writing to a pipe whose other end has closed

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching BrokenPipeError
try:
    raise BrokenPipeError("broken pipe")
except BrokenPipeError as e:
    print(f"Caught BrokenPipeError: {e}")
    print(f"Type: {type(e).__name__}")

BrokenPipeError is raised when raised when writing to a pipe whose other end has closed. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore