1. 程式人生 > >關於celery的bug解決方法:AttributeError: module 'celery_tasks' has no attribute 'celery'

關於celery的bug解決方法:AttributeError: module 'celery_tasks' has no attribute 'celery'

最近寫程式碼突然出現了關於celery屬性出錯的問題,在網上查了很久也沒有找到解決方法,後來重新檢查程式碼才發現是程式碼的寫錯誤了。

Bug截圖

AttributeError: module 'celery_tasks' has no attribute 'celery'

解決方法

  • 檢查程式碼是否出錯:
    錯誤程式碼:celery -A celery_tasks worker -l info
    正確程式碼:celery -A celery_tasks.main worker -l info'
    分析:celery屬性是在main檔案中,只有執行了main檔案才能找到celery屬性
    在這裡插入圖片描述