49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
測試Celery導入
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
|
|
# Fix encoding for Windows console
|
|
if sys.stdout.encoding != 'utf-8':
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
if sys.stderr.encoding != 'utf-8':
|
|
sys.stderr.reconfigure(encoding='utf-8')
|
|
|
|
def test_celery_import():
|
|
"""測試Celery是否能正確導入"""
|
|
try:
|
|
print("嘗試導入app模組...")
|
|
import app
|
|
print(f"✅ app模組導入成功: {app}")
|
|
|
|
print("檢查app模組屬性...")
|
|
print(f" - hasattr(app, 'app'): {hasattr(app, 'app')}")
|
|
print(f" - hasattr(app, 'celery'): {hasattr(app, 'celery')}")
|
|
|
|
if hasattr(app, 'celery'):
|
|
celery_instance = app.celery
|
|
print(f"✅ celery實例: {celery_instance}")
|
|
print(f" - celery類型: {type(celery_instance)}")
|
|
print(f" - celery任務: {list(celery_instance.tasks.keys())}")
|
|
else:
|
|
print("❌ app模組沒有celery屬性")
|
|
|
|
if hasattr(app, 'app'):
|
|
flask_app = app.app
|
|
print(f"✅ Flask app: {flask_app}")
|
|
if hasattr(flask_app, 'celery'):
|
|
print(f"✅ Flask app.celery: {flask_app.celery}")
|
|
else:
|
|
print("❌ Flask app沒有celery屬性")
|
|
|
|
except Exception as e:
|
|
print(f"❌ 導入失敗: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
if __name__ == "__main__":
|
|
test_celery_import() |