code: def send_heartbeat(self):
          '''
          Send a heartbeat if needed. Tracks last heartbeat send time.
          '''
          # Note that this does not take into account the time that we last
          # sent a frame. Hearbeats are so small the effect should be quite
          # limited. Also note that we're looking for something near to our
          # scheduled interval, because if this is exact, then we'll likely
          # actually send a heartbeat at twice the period, which could cause
          # a broker to kill the connection if the period is large enough. The
          # 90% bound is arbitrary but seems a sensible enough default.
          if self.connection._heartbeat:
              if time.time() >= (self._last_heartbeat_send + 0.9 *
                                 self.connection._heartbeat):
                  self.send_frame(HeartbeatFrame(self.channel_id))
                  self._last_heartbeat_send = time.time(f send_heartbeat(self):
          '''
          Send a heartbeat if needed. Tracks last heartbeat send time.
          '''
          # Note that this does not take into account the time that we last
          # sent a frame. Hearbeats are so small the effect should be quite
          # limited. Also note that we're looking for something near to our
          # scheduled interval, because if this is exact, then we'll likely
          # actually send a heartbeat at twice the period, which could cause
          # a broker to kill the connection if the period is large enough. The
          # 90% bound is arbitrary but seems a sensible enough default.
          if self.connection._heartbeat:
              if time.time() >= (self._last_heartbeat_send + 0.9 *
                                 self.connection._heartbeat):
                  self.send_frame(HeartbeatFrame(self.channel_id))
                  self._last_heartbeat_send = time.time()
docs: Send a heartbeat if needed. Tracks last heartbeat send time.