code: def is_socket_closed(sock):     # pragma    nocover
      
      if not sock:
          return True
      try:
          if not poll:    # pragma nocover
              if not select:
                  return False
              try:
                  return bool(select([sock], [], [], 0.0)[0])
              except socket.error:
                  return True
          # This version is better on platforms that support it.
          p = poll()
          p.register(sock, POLLIN)
          for (fno, ev) in p.poll(0.0):
              if fno == sock.fileno():
                  # Either data is buffered (bad), or the connection is dropped.
                  return True
      except Exception:
          return True
docs: Check if socket ``sock`` is closed.