queue
queue copied to clipboard
[17.0][FIX] Refactor stop signal handling in QueueJobRunner
This commit addresses the issue: https://github.com/OCA/queue/issues/564.
Refactor QueueJobRunner to Enhance Performance, Signal Handling, and Stability
This pull request brings substantial improvements and new functionalities to the QueueJobRunner, which is focused on optimizing performance, signal handling, and stability. The significant changes include the transition to asynchronous HTTP requests, dynamic detection of new databases, and enhancements for robust signal handling.
Key Changes:
-
Async HTTP Requests:
- Transitioned from threading-based requests to
asyncioandaiohttpfor handling HTTP job runs asynchronously. This change enhances concurrency and network-bound operation efficiency.
- Transitioned from threading-based requests to
-
Socket Pair for Signal Handling:
- Implemented socket pairs to effectively manage stop signals, ensuring compatibility across UNIX and Windows environments.
-
Selectors for Notification Handling:
- Adopted
selectors.DefaultSelector()for handling database and stop signal notifications, improving efficiency and scalability of notification handling.
- Adopted
-
Auto-Detection of New Databases:
- Added functionality for periodically checking and initializing newly created databases with the
queue_jobmodule installed, allowing dynamic adaptation without server restart.
- Added functionality for periodically checking and initializing newly created databases with the
-
Configurable Check Interval:
- Introduced a parameter for setting the check interval for new databases, enabling a balance between responsiveness and system overhead.
-
Database Keep-Alive Mechanism:
- Added periodic
SELECT 1queries to keep database connections alive and prevent intermediaries from closing idle connections.
- Added periodic
Please review the changes and provide feedback or approval for merging this enhanced version of the QueueJobRunner. These improvements address the aforementioned issue and the todo's included within the original file, increasing robustness, scalability, and overall performance. I have included test cases and attempted to comply with pre-commit tests, with the aim of achieving a green checkmark.
Thank you for your consideration.
Hi @guewen, some modules you are maintaining are being modified, check this out!
There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.