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

Method install_hook

tornado/test/websocket_test.py:872–890  ·  view source on GitHub ↗

Optionally suppress the client's "pong" response.

(ws)

Source from the content-addressed store, hash-verified

870
871 @staticmethod
872 def install_hook(ws):
873 """Optionally suppress the client's "pong" response."""
874
875 ws.drop_pongs = False
876 ws.pongs_received = 0
877
878 def wrapper(fcn):
879 def _inner(opcode: int, data: bytes):
880 if opcode == 0xA: # NOTE: 0x9=ping, 0xA=pong
881 ws.pongs_received += 1
882 if ws.drop_pongs:
883 # prevent pong responses
884 return
885 # leave all other responses unchanged
886 return fcn(opcode, data)
887
888 return _inner
889
890 ws.protocol._handle_message = wrapper(ws.protocol._handle_message)
891
892 @gen_test
893 def test_client_ping_timeout(self):

Callers 1

Calls 1

wrapperFunction · 0.50

Tested by

no test coverage detected