Overview
TheQueueManager singleton provides per-user concurrency limiting for video info extraction:
Architecture
Singleton pattern
The queue manager uses a singleton to ensure only one instance exists:Per-user tracking
The manager tracks how many requests each user has in the queue:Configuration
Queue limits are configured in.env:
Usage
Basic usage with context manager
Pre-check before acquiring
The handler checks queue limits before starting processing:Bypass for inline mode
Inline downloads can bypass per-user limits:Slot acquisition
Acquire logic
Release logic
Queue monitoring
Get user queue count
Get active users count
Error messages
When queue is full, users see a localized message with retry button:Thread safety
All queue operations are protected by an async lock:- No race conditions during concurrent acquires/releases
- Accurate count tracking
- Safe dictionary modifications
Queue vs. no global queue
Important: The bot only limits concurrent info extractions per user. There is no global send queue:- Prevents one user from blocking others during slow extractions
- Allows unlimited parallel sends (limited by Telegram rate limits)
- Balances resource usage with responsiveness

