code: def socket_closed(self, sock):
          
          while True:
              try:
                  if self._poller:
                      with self._lock:
                          self._poller.register(sock, _EVENT_MASK)
                          try:
                              rd = self._poller.poll(0)
                          finally:
                              self._poller.unregister(sock)
                  else:
                      rd, _, _ = select.select([sock], [], [], 0)
              except (RuntimeError, KeyError):
                  # RuntimeError is raised during a concurrent poll. KeyError
                  # is raised by unregister if the socket is not in the poller.
                  # These errors should not be possible since we protect the
                  # poller with a mutex.
                  raise
              except ValueError:
                  # ValueError is raised by register/unregister/select if the
                  # socket file descriptor is negative or outside the range for
                  # select (> 1023).
                  return True
              except (_SELECT_ERROR, IOError) as exc:
                  if _errno_from_exception(exc) in (errno.EINTR, errno.EAGAIN):
                      continue
                  return True
              except Exception:
                  # Any other exceptions should be attributed to a closed
                  # or invalid socket.
                  return True
              return len(rd) > 0
docs: Return True if we know socket has been closed, False otherwise.