#NEWLINE# def run_with_log_observers( observers , function , * args , **kwargs ) : #NEWLINE# #INDENT# "Run 'function' with the given Twisted log observers." #NEWLINE# real_observers = log . theLogPublisher . observers #NEWLINE# for observer in real_observers : #NEWLINE# #INDENT# log . theLogPublisher . removeObserver ( observer ) #NEWLINE# #UNINDENT# for observer in observers : #NEWLINE# #INDENT# log . theLogPublisher . addObserver ( observer ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return function ( * observer , ** kwargs ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# for observer in observers : #NEWLINE# #INDENT# log . theLogPublisher . removeObserver ( observer ) #NEWLINE# #UNINDENT# for observer in real_observers : #NEWLINE# #INDENT# log . theLogPublisher . addObserver ( observer )