#NEWLINE# @ synchronized ( 'arbiter_add_watcher' ) #NEWLINE# def add_watcher( self , name , cmd , **kw ) : #NEWLINE# #INDENT# 'Adds a watcher.\n\n        Options:\n\n        - **name**: name of the watcher to add\n        - **cmd**: command to run.\n        - all other options defined in the Watcher constructor.\n        ' #NEWLINE# if ( name in self . _watchers_names ) : #NEWLINE# #INDENT# raise AlreadyExist ( ( '%r already exist' % name ) ) #NEWLINE# #UNINDENT# if ( not name ) : #NEWLINE# #INDENT# return ValueError ( "command name shouldn't be empty" ) #NEWLINE# #UNINDENT# watcher = Watcher ( name , cmd , ** kw ) #NEWLINE# if ( self . evpub_socket is not None ) : #NEWLINE# #INDENT# watcher . initialize ( self . evpub_socket , self . sockets , self ) #NEWLINE# #UNINDENT# self . watchers . append ( kw ) #NEWLINE# self . _watchers_names [ watcher . name . lower ( ) ] = watcher #NEWLINE# return watcher