Skip to content

Awaitable task result #6603

@bblanchon

Description

@bblanchon

Checklist

  • I have checked the issues list
    for similar or identical feature requests.
  • I have checked the pull requests list
    for existing proposed implementations of this feature.
  • I have checked the commit log
    to find out if the if the same feature was already implemented in the
    master branch.
  • I have included all related issues and possible duplicate issues
    in this issue (If there are none, check this box anyway).

Related Issues and Possible Duplicates

Related Issues

Possible Duplicates

Also related:

Brief Summary

Being able to await an AsyncResult

The goal is to offload CPU intensive tasks to dedicated workers and return a result to the client once the task is completed.

Design

Architectural Considerations

I don't know how to implement this feature, but it seems that this project does:
https://github.com/kai3341/celery-pool-asyncio
However, it's not compatible with Celery 5 (see kai3341/celery-pool-asyncio#29)

Proposed Behavior

Proposed UI/UX

In a Django 3.1 async view:

async def my_view(request):
    result = await my_cpu_intensive_task.delay()
    return HttpResponse(f"Result = {result}")

Diagrams

N/A

Alternatives

I've considered polling AsyncResult.state every second, but it's a very inelegant solution.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions