#NEWLINE# def __exit__( self , exc_type , exc_val , exc_tb ) : #NEWLINE# #INDENT# if ( ( exc_type is None ) and ( self . _spawn_method is not None ) ) : #NEWLINE# #INDENT# fut = None #NEWLINE# try : #NEWLINE# #INDENT# fut = self . _spawn_method ( * self . _spawn_args , ** self . _spawn_kwargs ) #NEWLINE# fut . add_done_callback ( self . _thread_release_resources ) #NEWLINE# return #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# with excutils . save_and_reraise_exception ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if e . _on_error_method : #NEWLINE# #INDENT# self . _on_error_method ( e , * self . _on_error_args , ** self . _on_error_kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# LOG . warning ( _LW ( "Task's on_error hook failed to call %(method)s on node %(node)s" ) , { #NEWLINE# #INDENT# 'method' : self . _on_error_method . __name__ , #NEWLINE# 'node' : self . node . uuid , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# if ( fut is not None ) : #NEWLINE# #INDENT# fut . cancel ( ) #NEWLINE# #UNINDENT# self . release_resources ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . release_resources ( )