#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def run_with_dependencies( self ) : #NEWLINE# #INDENT# if ( not self . is_enabled ( ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . listener = ( yield self . cancellable ( self . listener_dependency . wait_for_resource ( ) ) ) #NEWLINE# if e . lock_name : #NEWLINE# #INDENT# ( yield self . cancellable ( self . listener . wait_for_advisory_lock ( self . lock_name ) ) ) #NEWLINE# #UNINDENT# ( yield self . cancellable ( self . run_as_leader ( ) ) ) #NEWLINE# #UNINDENT# except defer . CancelledError : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# logger . exception ( 'unhandled exception' ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# self . listener . release_lock ( self . lock_name ) #NEWLINE# ( yield self . wait ( ) )