def generation_if_stable(self):
        """Get the current generation state if the group is stable.

        Returns: the current generation or None if the group is unjoined/rebalancing
        """
        with self._lock:
            if self.state is not MemberState.STABLE:
                return None
            return self._generation
Get the current generation state if the group is stable.

        Returns: the current generation or None if the group is unjoined/rebalancing
        
kafka/coordinator/base.py