Skip to content

Celery with asyncio? #321

Closed
Closed
@downdawn

Description

@downdawn

Hi, @wu-clan

Celery scheduled tasks cannot be executed

bdb52e620133cb39d87751f53ed28ea

Solutions related to asyncio
https://stackoverflow.com/questions/39815771/how-to-combine-celery-with-asyncio

5b0e766934b4c6826ddfc9611064a87

The method above uses async_to_sync to forcibly convert to a synchronous method, which runs normally on the Windows 10 system, but requires additional configuration.

# windows 下需要设置环境变量,不推荐使用 windows 下开发 celery
# https://github.com/celery/celery/pull/4078
#
import os

os.environ.setdefault('FORKED_BY_MULTIPROCESSING', '1')

In the CentOS 7 system environment, after deployment using Supervisor and Gunicorn, observe it several times and an exception may occur.
image

If Celery cannot be compatible with asyncio, then performing database operations within tasks will be affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions