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

Method ping

tornado/websocket.py:450–469  ·  view source on GitHub ↗

Send ping frame to the remote end. The data argument allows a small amount of data (up to 125 bytes) to be sent as a part of the ping message. Note that not all websocket implementations expose this data to applications. Consider using the ``websocket_ping_i

(self, data: Union[str, bytes] = b"")

Source from the content-addressed store, hash-verified

448 raise NotImplementedError
449
450 def ping(self, data: Union[str, bytes] = b"") -> None:
451 """Send ping frame to the remote end.
452
453 The data argument allows a small amount of data (up to 125
454 bytes) to be sent as a part of the ping message. Note that not
455 all websocket implementations expose this data to
456 applications.
457
458 Consider using the ``websocket_ping_interval`` application
459 setting instead of sending pings manually.
460
461 .. versionchanged:: 5.1
462
463 The data argument is now optional.
464
465 """
466 data = utf8(data)
467 if self.ws_connection is None or self.ws_connection.is_closing():
468 raise WebSocketClosedError()
469 self.ws_connection.write_ping(data)
470
471 def on_pong(self, data: bytes) -> None:
472 """Invoked when the response to a ping frame is received."""

Callers 1

test_manual_pingMethod · 0.45

Calls 4

utf8Function · 0.90
is_closingMethod · 0.45
write_pingMethod · 0.45

Tested by 1

test_manual_pingMethod · 0.36