<s> """<STR_LIT>""" <EOL> from kazoo . exceptions import CancelledError <EOL> class Election ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , client , path , identifier = None ) : <EOL> """<STR_LIT>""" <EOL> self . lock = client . Lock ( path , identifier ) <EOL> def run ( self , func , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if not callable ( func ) : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> try : <EOL> with self . lock : <EOL> func ( * args , ** kwargs ) <EOL> except CancelledError : <EOL> pass <EOL> def cancel ( self ) : <EOL> """<STR_LIT>""" <EOL> self . lock . cancel ( ) <EOL> def contenders ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . lock . contenders ( ) </s>
