This avoids a (harmless) crash when the output of djbdns-logparse is
piped to a process (such as head/tail) that closes the pipe before
djbdns-logparse is done writing to it.
if not friendly_line:
friendly_line = line
- print(friendly_line)
+ try:
+ print(friendly_line)
+ except BrokenPipeError:
+ # If our stdout is being piped to another process and if
+ # that process closes the pipe, this error will be raised
+ # the next time we try to write to stdout.
+ break
# Ensure that the pipe gets closed.
tai.communicate()