#NEWLINE# def task_autoretry( * args_task , **kwargs_task ) : #NEWLINE# #INDENT# def actual_decorator( func ) : #NEWLINE# #INDENT# @ app . task ( * args_task , ** kwargs_task ) #NEWLINE# @ functools . wraps ( func ) #NEWLINE# def wrapper( * args , **kwargs ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return func ( * args , ** kwargs ) #NEWLINE# #UNINDENT# except kwargs_task . get ( 'autoretry_on' , Exception ) as exc : #NEWLINE# #INDENT# logger . info ( 'Retrying with exception {}' . format ( exc ) ) #NEWLINE# raise wrapper . retry ( exc = exc ) #NEWLINE# #UNINDENT# #UNINDENT# return wrapper #NEWLINE# #UNINDENT# return args_task