'Get the number of returning repeats for limited Scripts.
Returns:
remaining (int or `None`): The number of repeats
remaining until the Script stops. Returns `None`
if it has unlimited repeats.'

def remaining_repeats(self):

    task = self.ndb._task
    if task:
        return max(0, (self.db_repeats - task.callcount))
    return None
