code: def _keepAlive(self):
      if self.__lastSeen is None:
          return
  
      # Check if we're under the inactivity threshold.
      inactivity = time.time() - self.__lastSeen
      if inactivity <= self.__activityTimeout:
          return
  
      # Send keep alive if it was not sent,
      # or check if we have to timeout waiting for the keep alive response.
      try:
          if self.__kaSent is None:
              self.sendKeepAlive()
              self.__kaSent = time.time()
          elif (time.time() - self.__kaSent) > self.__responseTimeout:
              self.__wsClient.onDisconnectionDetected()
      except Exception:
          # Treat an error sending the keep-alive as a diconnection.
          # print "Error sending keep alive", e
          self.__wsClient.onDisconnectionDetected()
  
imports: import json
  import time
  import threading
  import six
  from ws4py.client import tornadoclient
  import tornado
  import pyalgotrade.logger
label_desc: Use image node_id 2 for calling the KeepAliveMgr obj's underlying member method code with example usage: obj._keepAlive() without return types