예제 #1
0
def longtask():
    task = long_task.apply_async()  #aqui task sera 'long_task'
    return jsonify({}), 202, {
        'Location':
        url_for(
            'taskstatus',  # regresara jsonify con 202 para decir que esta trabajando
            task_id=task.id)
    }
예제 #2
0
파일: app.py 프로젝트: tracywuhuan/covid19
def longtask():
    task = long_task.apply_async()
    return jsonify({}), 202, {
        'Location': url_for('taskstatus', task_id=task.id)
    }
예제 #3
0
from tasks import add, fail, long_task

tsk = long_task.apply_async(args=[23])

resp = long_task.AsyncResult(tsk.id)

result = add.delay(4, 4)

result.apply_async

result.ready()

result.get(timeout=1)

result.get(propagate=False)

result.traceback

result = fail.delay(4)

result.ready()

result.get(timeout=1)

result.get(propagate=False)

result.traceback
예제 #4
0
     'rate_limit': '10/m'
 }, reply=True)
 print('Reply: %s' % reply)
 
 
 # revoke a task
 result = long_task.delay()
 time.sleep(3)
 # below is equal to: result.revoke()
 app.control.revoke(result.task_id, terminate=True)
 
 # time limit don’t currently work on platforms that don’t support the SIGUSR1 signal.
 # so it cannot work on Windows.
 reply = app.control.time_limit('tasks.long_task', soft=10, hard=20, reply=True)
 print('Reply: %s' % reply)
 long_task.apply_async()
 
 
 # add consumer
 reply = app.control.add_consumer(
     queue='baz',
     exchange='ex',
     exchange_type='topic',
     routing_key='media.*',
     options={
         'queue_durable': False,
         'exchange_durable': False,
     },
     reply=True
 )
 print('Reply: %s' % reply)
예제 #5
0
def start_celery_long_task():
    long_task.apply_async((10, 'task-1', '/managers'))
def longtask():
    task = long_task.apply_async()
    return jsonify({}), 202, {'Location': url_for('home.taskstatus',
                                                  task_id=task.id)}