code: def _check_for_life_signs(self):
          
          if not self._running.is_set():
              return False
          if self._writes_since_check == 0:
              self.send_heartbeat_impl()
          self._lock.acquire()
          try:
              if self._reads_since_check == 0:
                  self._threshold += 1
                  if self._threshold >= 2:
                      self._running.clear()
                      self._raise_or_append_exception()
                      return False
              else:
                  self._threshold = 0
          finally:
              self._reads_since_check = 0
              self._writes_since_check = 0
              self._lock.release()
  
          return self._start_new_timer()
docs: Check Connection for life signs.
  
              First check if any data has been sent, if not send a heartbeat
              to the remote server.
  
              If we have not received any data what so ever within two
              intervals, we need to raise an exception so that we can
              close the connection.
  
          :rtype: bool