MCPcopy
hub / github.com/tornadoweb/tornado / close_all_connections

Method close_all_connections

tornado/httpserver.py:216–233  ·  view source on GitHub ↗

Close all open connections and asynchronously wait for them to finish. This method is used in combination with `~.TCPServer.stop` to support clean shutdowns (especially for unittests). Typical usage would call ``stop()`` first to stop accepting new connections, then

(self)

Source from the content-addressed store, hash-verified

214 return HTTPServer
215
216 async def close_all_connections(self) -> None:
217 """Close all open connections and asynchronously wait for them to finish.
218
219 This method is used in combination with `~.TCPServer.stop` to
220 support clean shutdowns (especially for unittests). Typical
221 usage would call ``stop()`` first to stop accepting new
222 connections, then ``await close_all_connections()`` to wait for
223 existing connections to finish.
224
225 This method does not currently close open websocket connections.
226
227 Note that this method is a coroutine and must be called with ``await``.
228
229 """
230 while self._connections:
231 # Peek at an arbitrary element of the set
232 conn = next(iter(self._connections))
233 await conn.close()
234
235 def handle_stream(self, stream: iostream.IOStream, address: Tuple) -> None:
236 context = _HTTPRequestContext(

Callers 1

slow_stopMethod · 0.80

Calls 1

closeMethod · 0.45

Tested by 1

slow_stopMethod · 0.64