Object property getter infinite loop Here is my issue : I would like to add a unique Int property on an object. 

This property needs to be unique even when duplicated.
So according to Duplicating object and default value of property and https://blenderartists.org/forum/showthread.php?328009-Unique-object-id I did this :

# Getter for anchor duplicate
def get_global_index(self):
#    print("getting value")
    done = False
    # get current index
    index = self.global_index #Recursive ?!
    # chek if already used (in case of a duplicate) and try a new one while necessary
    while not done:
        anchors = [obj for obj in bpy.context.scene.objects if obj.type == 'EMPTY' and obj.empty_draw_type == 'PLAIN_AXES']
        # already referenced
        if any(obj.global_index == self.global_index for obj in anchors):
            # found to try another index
            print("Trying another index")
            index = context.scene.global_index
            context.scene.global_index+=1
        else:
            done = True
            print("FOUND index")

    return index

def register():
    bpy.types.Object.list_index = bpy.props.IntProperty(name = "Index for my_list", default = 0)
    #Each anchor needs a unique index
    bpy.types.Scene.global_index = bpy.props.IntProperty(name = "Global index for Anchors", default = 0)
    #So use scene index to store the increment
    bpy.types.Object.global_index = bpy.props.IntProperty(name = "Object index for Anchors", default = 0, get=get_global_index)


BUT, The getter seems to loop infinitely and I don't understand what I'm doing wrong.
I just want the getter to check in the current objects of the specified king to check if the index is not already used (when Duplicated) because I need to have each one of them having a unique index.

Thanks !
So, based on this Duplicating object and default value of property I think I found a way.

I use a second identical property to avoid having to get from the getter

Here it is : 

# Getter for anchor duplicate
def get_global_index(self):


    # get current index
    index = self.hidden_index

    # chek if already used (in case of a duplicate) and try a new one while necessary
    # Do not forget to remove self from result !    
    anchors = [obj for obj in bpy.context.scene.objects if obj.type == 'EMPTY' and obj.empty_draw_type == 'PLAIN_AXES' and obj != self]

    while any(obj.hidden_index == index for obj in anchors):
        # found to try another index
        index +=1


    self.hidden_index = index;
    return self.hidden_index

def register():
    bpy.types.Object.global_index = bpy.props.IntProperty(name = "Object index for Anchors", default = 0, get=get_global_index)
    bpy.types.Object.hidden_index = bpy.props.IntProperty(default = 0, options={'HIDDEN'})


Since it the getter, I just need to return the new value. Using an other property without getter but with the same value, I can get the copied value from the getter.