#NEWLINE# def register( self , service_name , instance , timeout = 1 , namespace = SERVICE_NAMESPACE ) : #NEWLINE# #INDENT# path = self . _get_zk_path ( namespace , service_name , instance . id ) #NEWLINE# value = json . dumps ( instance . serialize ( ) ) #NEWLINE# try : #NEWLINE# #INDENT# self . client . delete ( path ) #NEWLINE# #UNINDENT# except NoNodeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# result = self . client . create_async ( path , value . encode ( 'utf-8' ) , ephemeral = True , makepath = True ) #NEWLINE# try : #NEWLINE# #INDENT# result . get ( timeout = timeout ) #NEWLINE# #UNINDENT# except gevent . Timeout : #NEWLINE# #INDENT# logger . exception ( 'registration of %s:%s failed' , namespace , service_name ) #NEWLINE# raise #NEWLINE# #UNINDENT# self . registered_names [ ( namespace , service_name ) ] = instance