Auto-commit: v2.10 — Fix Huey consumer never starting (loglevel= TypeError)
Root cause: Consumer(huey, workers=1, worker_type='thread', loglevel=20) raised TypeError on every app start because Huey 2.6.0 does not accept a `loglevel` keyword argument. The exception was silently caught and only printed to stdout, so the consumer never ran and all tasks stayed 'queued' forever — causing the 'Preparing environment / Waiting for logs' hang. Fixes: - web/app.py: Remove invalid `loglevel=20` from Consumer(); configure Huey logging via logging.basicConfig(WARNING) instead. Add persistent error logging to data/consumer_error.log for future diagnosis. - core/config.py: Replace emoji print() calls with ASCII-safe equivalents to prevent UnicodeEncodeError on Windows cp1252 terminals at import time. - core/config.py: Update VERSION to 2.9 (was stale at 1.5.0). - ai_blueprint.md: Bump to v2.10, document root cause and fixes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
19
web/app.py
19
web/app.py
@@ -97,13 +97,26 @@ with app.app_context():
|
||||
import threading as _threading
|
||||
|
||||
def _start_huey_consumer():
|
||||
import logging as _logging
|
||||
_logging.basicConfig(level=_logging.WARNING)
|
||||
try:
|
||||
from huey.consumer import Consumer
|
||||
consumer = Consumer(huey, workers=1, worker_type='thread', loglevel=20)
|
||||
print("✅ System: Huey task consumer started.")
|
||||
consumer = Consumer(huey, workers=1, worker_type='thread')
|
||||
print("System: Huey task consumer started.")
|
||||
consumer.run()
|
||||
except Exception as e:
|
||||
print(f"⚠️ System: Huey consumer failed to start: {e}")
|
||||
msg = f"System: Huey consumer failed to start: {e}"
|
||||
print(msg)
|
||||
# Write the error to a persistent log so it is visible even when stdout is lost
|
||||
try:
|
||||
import os as _os
|
||||
from core import config as _cfg
|
||||
_err_path = _os.path.join(_cfg.DATA_DIR, "consumer_error.log")
|
||||
with open(_err_path, 'a', encoding='utf-8') as _f:
|
||||
import datetime as _dt
|
||||
_f.write(f"[{_dt.datetime.now()}] {msg}\n")
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
_is_reloader_child = os.environ.get('WERKZEUG_RUN_MAIN') == 'true'
|
||||
_is_testing = os.environ.get('FLASK_TESTING') == '1'
|
||||
|
||||
Reference in New Issue
Block a user