31 lines
911 B
Python
31 lines
911 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Queue configuration using RedisHuey for asynchronous file processing.
|
|
"""
|
|
|
|
import logging
|
|
from huey import RedisHuey
|
|
from datetime import timedelta
|
|
|
|
from utils.settings import REDIS_URL
|
|
|
|
# Configure logging
|
|
logger = logging.getLogger('app')
|
|
|
|
# Initialize RedisHuey
|
|
# Redis is an external backend shared between the web (enqueue) and consumer
|
|
# (dequeue) processes, avoiding the local SQLite file corruption that the
|
|
# previous SqliteHuey backend suffered from under concurrent multi-process access.
|
|
huey = RedisHuey(
|
|
name='file_processor', # Queue name, used as the Redis key prefix
|
|
url=REDIS_URL,
|
|
always_eager=False, # Set to False to enable async processing
|
|
utc=True, # Use UTC time
|
|
)
|
|
|
|
# Set default task configuration
|
|
huey.max_retries = 3 # Maximum retry count
|
|
huey.retry_delay = timedelta(seconds=60) # Retry delay
|
|
|
|
logger.info("RedisHuey queue initialized")
|