Пример #1
0
async def root(word: str):
    task_name = "worker.celery_worker.long_task"
    # task = long_task.apply_async(args=[word])
    task = celery_app.send_task(task_name, args=[word])
    # background_task.add_task(background_on_message, task)

    return {"task_id": task.id}
Пример #2
0
async def root(word: str, background_task: BackgroundTasks):
    task_name = "worker.celery_worker.test_celery"

    task = celery_app.send_task(task_name, args=[word])
    print(task)
    background_task.add_task(background_on_message, task)

    return {"message": "Word received"}
Пример #3
0
async def root(word: str, background_task: BackgroundTasks):
    task_name = 'app.worker.celery_worker.test_celery'

    task = celery_app.send_task(task_name, args=[word])
    background_task.add_task(background_on_message, task)
    print(task)

    return {'message': 'Word received'}
Пример #4
0
async def root(item_id: str, background_task: BackgroundTasks):
    task_name = None
    task_name = "app.app.worker.celery_worker.test_celery"

# Send task to celery worker
    task = celery_app.send_task(task_name, args=[item_id])
    print(task)
    background_task.add_task(background_on_message, task)

    return {"message": "item_id received"}
Пример #5
0
async def root(word: str, background_task: BackgroundTasks):
    task_name = None

    # set correct task name based on the way you run the example
    if not bool(os.getenv('DOCKER')):
        task_name = "app.worker.celery_worker.test_celery"
    else:
        task_name = "app.app.worker.celery_worker.test_celery"

    task = celery_app.send_task(task_name, args=[word])
    print(task)
    background_task.add_task(background_on_message, task)

    return {"message": "Word received"}
Пример #6
0
async def root(iter_delay: int, background_task: BackgroundTasks):
    task = celery_app.send_task("app.worker.celery_worker.test_celery",
                                args=[iter_delay])
    background_task.add_task(background_on_message, task)
    return {"message": "task started", "task_id": task.id}
Пример #7
0
async def call_add1(background_task: BackgroundTasks):
    task = celery_app.send_task('worker.celery_worker.add1', args=[4, 5])
    print(task)
    background_task.add_task(background_on_message, task)
    return {"message": "add1 called"}