Skip to main content
 首页 » 编程设计

python之如何在django 1.10中使用异步任务在后台运行

2024年08月21日34pengyingh

我正在寻找可在我的 Django 1.10 网络项目中使用的选项,我需要在该项目中每小时运行一些任务。我知道我可以使用 DJCELERY,但它没有针对 Django 1.10 进行更新,我收到了这些错误,

Error fetching command 'celerymon': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celerymon' skipped 
Error fetching command 'celerybeat': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celerybeat' skipped 
Error fetching command 'celeryd_multi': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celeryd_multi' skipped 
Error fetching command 'celeryd': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celeryd' skipped 
Error fetching command 'celerycam': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celerycam' skipped 
Error fetching command 'celery': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celery' skipped 
Error fetching command 'celeryd_detach': type object 'BaseCommand' has no attribute 'option_list' 
Command 'celeryd_detach' skipped 
Error fetching command 'djcelerymon': type object 'BaseCommand' has no attribute 'option_list' 
Command 'djcelerymon' skipped 

那么我可以使用任何其他选项在后台运行任务吗? django 在新版本中是否提供类似的东西?

谢谢。

请您参考如下方法:

您可以使用 Celery 4,它不需要 django-celery 并且与 Django 1.10 兼容。阅读 Celery Documentation看看它是如何与 Django 集成的。