#NEWLINE# @ classmethod #NEWLINE# def AddInstance( cls , name ) : #NEWLINE# #INDENT# 'Adds new instance to the list of instances in Memcache.\n\n    Args:\n      name: Name of the instance.\n    ' #NEWLINE# SingleInstance ( key_name = name ) . put ( ) #NEWLINE# memcache_client = memcache . Client ( ) #NEWLINE# while True : #NEWLINE# #INDENT# instances = memcache_client . gets ( cls . ALL_INSTANCES ) #NEWLINE# if ( instances is None ) : #NEWLINE# #INDENT# logging . error ( 'all_instances entry in Memcache is None.' ) #NEWLINE# memcache . set ( cls . ALL_INSTANCES , [ name ] ) #NEWLINE# break #NEWLINE# #UNINDENT# if ( name in instances ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# instances . append ( name ) #NEWLINE# if memcache_client . cas ( cls . ALL_INSTANCES , instances ) : #NEWLINE# #INDENT# break