MCPcopy Index your code
hub / github.com/python-websockets/websockets / close

Method close

src/websockets/asyncio/server.py:408–436  ·  view source on GitHub ↗

Close the server. * Close the underlying :class:`asyncio.Server`. * When ``close_connections`` is :obj:`True`, which is the default, close existing connections. Specifically: * Reject opening WebSocket connections with an HTTP 503 (service u

(
        self,
        close_connections: bool = True,
        code: CloseCode | int = CloseCode.GOING_AWAY,
        reason: str = "",
    )

Source from the content-addressed store, hash-verified

406 self.handlers[connection] = self.loop.create_task(self.conn_handler(connection))
407
408 def close(
409 self,
410 close_connections: bool = True,
411 code: CloseCode | int = CloseCode.GOING_AWAY,
412 reason: str = "",
413 ) -> None:
414 """
415 Close the server.
416
417 * Close the underlying :class:`asyncio.Server`.
418 * When ``close_connections`` is :obj:`True`, which is the default, close
419 existing connections. Specifically:
420
421 * Reject opening WebSocket connections with an HTTP 503 (service
422 unavailable) error. This happens when the server accepted the TCP
423 connection but didn't complete the opening handshake before closing.
424 * Close open WebSocket connections with code 1001 (going away).
425 ``code`` and ``reason`` can be customized, for example to use code
426 1012 (service restart).
427
428 * Wait until all connection handlers terminate.
429
430 :meth:`close` is idempotent.
431
432 """
433 if self.close_task is None:
434 self.close_task = self.get_loop().create_task(
435 self._close(close_connections, code, reason)
436 )
437
438 async def _close(
439 self,

Callers 14

__aexit__Method · 0.95
handlerFunction · 0.45
handlerFunction · 0.45
receiveMovesFunction · 0.45
receiveMovesFunction · 0.45
receiveMovesFunction · 0.45
closeFunction · 0.45
first_message_handlerFunction · 0.45
interactive_clientFunction · 0.45
__aexit__Method · 0.45
connect_http_proxyFunction · 0.45
conn_handlerMethod · 0.45

Calls 2

get_loopMethod · 0.95
_closeMethod · 0.95

Tested by

no test coverage detected