<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def heartbeat(self):
 """Periodically send heartbeats."""

        while self._manager.is_active and not self._stop_event.is_set():
            self._manager.heartbeat()
            _LOGGER.debug("Sent heartbeat.")
            self._stop_event.wait(timeout=self._period)

        _LOGGER.info("%s exiting.", _HEARTBEAT_WORKER_NAME)