def CloseFdNoError(fd, retries=5):
  try:
    os.close(fd)
  except OSError, err:
    if err.errno != errno.EBADF:
      if retries > 0:
        CloseFdNoError(fd, retries - 1)
    # else either it's closed already or we're out of retries, so we
    # ignore this and go on
Close a file descriptor ignoring errors.
dataset/ETHPy150Open ganeti/ganeti/lib/utils/wrapper.py/CloseFdNoError