Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery with asyncio? #321

Closed
downdawn opened this issue May 4, 2024 · 4 comments
Closed

Celery with asyncio? #321

downdawn opened this issue May 4, 2024 · 4 comments

Comments

@downdawn
Copy link
Collaborator

downdawn commented May 4, 2024

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.

@downdawn
Copy link
Collaborator Author

downdawn commented May 6, 2024

celery/celery#8325

@wu-clan
Copy link
Member

wu-clan commented Jul 26, 2024

celery/celery#7874

@wu-clan wu-clan added the deferred Delayed, pending further research or updates label Jul 26, 2024
@wu-clan
Copy link
Member

wu-clan commented Jul 26, 2024

Hi, @downdawn
Has successfully run the asynchronous task with a temporary solution, see pr TODO for details.

@wu-clan wu-clan removed the deferred Delayed, pending further research or updates label Jul 26, 2024
@wu-clan wu-clan closed this as completed Jul 27, 2024
@downdawn
Copy link
Collaborator Author

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants