queue icon indicating copy to clipboard operation
queue copied to clipboard

[17.0][FIX] Refactor stop signal handling in QueueJobRunner

Open Maralai opened this issue 1 year ago • 2 comments

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:

  1. Async HTTP Requests:

    • Transitioned from threading-based requests to asyncio and aiohttp for handling HTTP job runs asynchronously. This change enhances concurrency and network-bound operation efficiency.
  2. Socket Pair for Signal Handling:

    • Implemented socket pairs to effectively manage stop signals, ensuring compatibility across UNIX and Windows environments.
  3. Selectors for Notification Handling:

    • Adopted selectors.DefaultSelector() for handling database and stop signal notifications, improving efficiency and scalability of notification handling.
  4. Auto-Detection of New Databases:

    • Added functionality for periodically checking and initializing newly created databases with the queue_job module installed, allowing dynamic adaptation without server restart.
  5. Configurable Check Interval:

    • Introduced a parameter for setting the check interval for new databases, enabling a balance between responsiveness and system overhead.
  6. Database Keep-Alive Mechanism:

    • Added periodic SELECT 1 queries to keep database connections alive and prevent intermediaries from closing idle connections.

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.

Maralai avatar May 07 '24 20:05 Maralai

Hi @guewen, some modules you are maintaining are being modified, check this out!

OCA-git-bot avatar May 07 '24 20:05 OCA-git-bot

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.

github-actions[bot] avatar Sep 29 '24 12:09 github-actions[bot]