code: def _service_heartbeat_if_due(self):
          '''Sends service registry heartbeat if due'''
          due = False
          if self._service_registry:
              if not hasattr(self, "status_info"):
                  due = True
              else:
                  d = doublethink.utcnow() - self.status_info["last_heartbeat"]
                  due = d.total_seconds() > self.HEARTBEAT_INTERVAL
  
          if due:
              self._service_heartbeat(f _service_heartbeat_if_due(self):
          '''Sends service registry heartbeat if due'''
          due = False
          if self._service_registry:
              if not hasattr(self, "status_info"):
                  due = True
              else:
                  d = doublethink.utcnow() - self.status_info["last_heartbeat"]
                  due = d.total_seconds() > self.HEARTBEAT_INTERVAL
  
          if due:
              self._service_heartbeat()
docs: Sends service registry heartbeat if due