original_docstring: Gracefully stop server, processing all pending connections.
          
docstring: Gracefully stop server, processing all pending connections.
docstring_tokens: Gracefully stop server processing all pending connections .
code: async def stop(self):
          """Gracefully stop server, processing all pending connections.
          """
          # Do server shutdown and pending event handling first.
          # Server shutdown should ensure:
          # 1. No accepted connections are unhandled
          # 2. All pending asynchronous functions have returned
          # 3. All cleanup by the handler is done.
          logger.debug("Server.stop()")
          self._shutting_down = True
          with ExitStack() as stack:
              if self._shutdown_ctx:
                  stack.enter_context(self._shutdown_ctx)
              # Prevent timeout from occurring while we're shutting down.
              self._clear_idle_timer()
              # Closing the listener ensures there will be no more connections
              # queued.
              logger.debug("Waiting for listener close")
              await self._listener.close()
              logger.debug("Waiting for pending connections")
              async with self._shutdown_accept_cv:
                  await self._shutdown_accept_cv.wait()
              logger.debug("Waiting for handler shutdown")
              await self._handler.handle_shutdown()
              logger.debug("Waiting for shutdown callback")
              # Finish everything off.
              self._on_shutdown()
code_tokens: async def stop ( self ) : logger . debug ( "Server.stop()" ) self . _shutting_down = True with ExitStack ( ) as stack : if self . _shutdown_ctx : stack . enter_context ( self . _shutdown_ctx ) self . _clear_idle_timer ( ) logger . debug ( "Waiting for listener close" ) await self . _listener . close ( ) logger . debug ( "Waiting for pending connections" ) async with self . _shutdown_accept_cv : await self . _shutdown_accept_cv . wait ( ) logger . debug ( "Waiting for handler shutdown" ) await self . _handler . handle_shutdown ( ) logger . debug ( "Waiting for shutdown callback" ) self . _on_shutdown ( )
short_docstring: Gracefully stop server, processing all pending connections.
short_docstring_tokens: Gracefully stop server processing all pending connections .
comment: """Gracefully stop server, processing all pending connections.
          """$SEP$# Do server shutdown and pending event handling first.$SEP$# Server shutdown should ensure:$SEP$# 1. No accepted connections are unhandled$SEP$# 2. All pending asynchronous functions have returned$SEP$# 3. All cleanup by the handler is done.$SEP$# Prevent timeout from occurring while we're shutting down.$SEP$# Closing the listener ensures there will be no more connections$SEP$# queued.$SEP$# Finish everything off.