#NEWLINE# def task( self , retries = 0 , retry_delay = 0 , retries_as_argument = False , include_task = False , name = None ) : #NEWLINE# #INDENT# def decorator( func ) : #NEWLINE# #INDENT# '\n            Decorator to execute a function out-of-band via the consumer.\n            ' #NEWLINE# klass = create_task ( QueueTask , func , retries_as_argument , name , include_task ) #NEWLINE# def schedule( args = None , kwargs = None , eta = None , delay = None , convert_utc = True , task_id = None ) : #NEWLINE# #INDENT# if ( delay and eta ) : #NEWLINE# #INDENT# raise ValueError ( 'Both a delay and an eta cannot be specified at the same time' ) #NEWLINE# #UNINDENT# if delay : #NEWLINE# #INDENT# eta = ( datetime . datetime . now ( ) + datetime . timedelta ( seconds = delay ) ) #NEWLINE# #UNINDENT# if ( convert_utc and eta ) : #NEWLINE# #INDENT# eta = local_to_utc ( eta ) #NEWLINE# #UNINDENT# cmd = klass ( ( ( args or ( ) ) , ( kwargs or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) , execute_time = eta , retries = retries , retry_delay = retry_delay , task_id = task_id ) #NEWLINE# return self . enqueue ( cmd ) #NEWLINE# #UNINDENT# func . schedule = schedule #NEWLINE# func . task_class = klass #NEWLINE# @ wraps ( func ) #NEWLINE# def inner_run( * args , **kwargs ) : #NEWLINE# #INDENT# cmd = klass ( ( args , kwargs ) , retries = retries , retry_delay = retry_delay ) #NEWLINE# return self . enqueue ( cmd ) #NEWLINE# #UNINDENT# inner_run . call_local = func #NEWLINE# return inner_run #NEWLINE# #UNINDENT# return retries_as_argument