MCPcopy Create free account
hub / github.com/EasyIME/PIME / periodic_ping

Method periodic_ping

python/python3/tornado/websocket.py:1316–1341  ·  view source on GitHub ↗

Send a ping to keep the websocket alive Called periodically if the websocket_ping_interval is set and non-zero.

(self)

Source from the content-addressed store, hash-verified

1314 self.ping_callback.start()
1315
1316 def periodic_ping(self) -> None:
1317 """Send a ping to keep the websocket alive
1318
1319 Called periodically if the websocket_ping_interval is set and non-zero.
1320 """
1321 if self.is_closing() and self.ping_callback is not None:
1322 self.ping_callback.stop()
1323 return
1324
1325 # Check for timeout on pong. Make sure that we really have
1326 # sent a recent ping in case the machine with both server and
1327 # client has been suspended since the last ping.
1328 now = IOLoop.current().time()
1329 since_last_pong = now - self.last_pong
1330 since_last_ping = now - self.last_ping
1331 assert self.ping_interval is not None
1332 assert self.ping_timeout is not None
1333 if (
1334 since_last_ping < 2 * self.ping_interval
1335 and since_last_pong > self.ping_timeout
1336 ):
1337 self.close()
1338 return
1339
1340 self.write_ping(b"")
1341 self.last_ping = now
1342
1343 def set_nodelay(self, x: bool) -> None:
1344 self.stream.set_nodelay(x)

Callers

nothing calls this directly

Calls 6

is_closingMethod · 0.95
closeMethod · 0.95
write_pingMethod · 0.95
timeMethod · 0.80
currentMethod · 0.80
stopMethod · 0.45

Tested by

no test coverage detected