code: def safeprintf(file, format, *args):
      
      try:
          if args:
              file.write(format % args)
          else:
              file.write(format)
      except IOError, e:
          if e.errno == errno.EPIPE:
              # if our output is closed, exit; e.g. when logging over an
              # ssh connection and the ssh connection is closed
              os._exit(os.EX_OSERR)
docs: Write to a file object, ignoring errors.