code: def stop(self):
          
          self.ready = False
          if self._start_time is not None:
              self._run_time += (time.time() - self._start_time)
          self._start_time = None
  
          sock = getattr(self, 'socket', None)
          if sock:
              if not isinstance(self.bind_addr, six.string_types):
                  # Touch our own socket to make accept() return immediately.
                  try:
                      host, port = sock.getsockname()[:2]
                  except socket.error as ex:
                      if ex.args[0] not in errors.socket_errors_to_ignore:
                          # Changed to use error code and not message
                          # See
                          # https://github.com/cherrypy/cherrypy/issues/860.
                          raise
                  else:
                      # Note that we're explicitly NOT using AI_PASSIVE,
                      # here, because we want an actual IP to touch.
                      # localhost won't work if we've bound to a public IP,
                      # but it will if we bound to '0.0.0.0' (INADDR_ANY).
                      for res in socket.getaddrinfo(
                          host, port, socket.AF_UNSPEC,
                          socket.SOCK_STREAM,
                      ):
                          af, socktype, proto, canonname, sa = res
                          s = None
                          try:
                              s = socket.socket(af, socktype, proto)
                              # See
                              # https://groups.google.com/group/cherrypy-users/
                              #     browse_frm/thread/bbfe5eb39c904fe0
                              s.settimeout(1.0)
                              s.connect((host, port))
                              s.close()
                          except socket.error:
                              if s:
                                  s.close()
              if hasattr(sock, 'close'):
                  sock.close()
              self.socket = None
  
          self.requests.stop(self.shutdown_timeout)
docs: Gracefully shutdown a server that is serving forever.