<s> import abc <EOL> import functools <EOL> from oslo_utils import excutils <EOL> import six <EOL> def rollback_wrapper ( original ) : <EOL> @ functools . wraps ( original ) <EOL> def wrap ( self ) : <EOL> try : <EOL> return original ( self ) <EOL> except Exception : <EOL> with excutils . save_and_reraise_exception ( ) : <EOL> self . rollback ( ) <EOL> return wrap <EOL> @ six . add_metaclass ( abc . ABCMeta ) <EOL> class TaskBase ( object ) : <EOL> def __init__ ( self , context , instance ) : <EOL> self . context = context <EOL> self . instance = instance <EOL> @ rollback_wrapper <EOL> def execute ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _execute ( ) <EOL> @ abc . abstractmethod <EOL> def _execute ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def rollback ( self ) : <EOL> """<STR_LIT>""" <EOL> pass </s>
