Add --reload option to CLI worker command - #1451
Conversation
Implements uvicorn-style auto-reload functionality for the procrastinate worker CLI: CLI Options: - --reload: Enable auto-reload for development - --reload-dir: Specify directories to watch (multiple allowed) - --reload-include: Glob patterns to include (default: *.py) - --reload-exclude: Glob patterns to exclude - --reload-delay: Debounce delay for file changes (default: 0.25s) Technical Implementation: - Uses watchfiles library with inotify for efficient file watching - Supervisor/subprocess pattern for clean process isolation - Similar to uvicorn's reload mechanism - Graceful process restart with SIGTERM/SIGKILL fallback - Comprehensive logging and error handling Installation: - Requires procrastinate[reload] extra for watchfiles dependency - Uses inotify on Linux for optimal performance - Fallback to polling mode when needed Usage Examples: - procrastinate worker --reload - procrastinate worker --reload --reload-dir ./myapp --reload-dir ./tasks - procrastinate worker --reload --reload-include '*.py' --reload-exclude '*/tests/*' This significantly improves the developer experience when working with Procrastinate background tasks during development.
for more information, see https://pre-commit.ci
|
Restating my comment from #1450 (comment):
(I'm assuming this PR was vibecoded, due to its, well, vibes. Please let me know if it isn't the case) So: can you confirm that you have read and understood the code submitted here ? Also, since it's a PR without an issue, and the related discussion lead to an initial negative statement on implementing the issue: can you make a case on why we should do this rather than tell people to use watchdog? (I'd accept a documentation PR, even if vibecoded, as stated above) Please understand that seasoned vibecoders can make a PR like this in less than 5 minutes, for which I (and procrastinate maintainers) will be responsible for 1/ reviewing, 2/ supporting seemingly forever, so naturally, the bar is much higher for merging PRs that look vibecoded, it's not criticism, but a self defense mechanism. This project runs on volunteers time. Of course, with sufficient guidance, vibecoded PRs can end up being fine, but it's much more reassuring to know that there was a human dev involved in the loop. Thanks for your comprehension. |
This PR adds uvicorn-style auto-reload functionality to the CLI command, enabling efficient development workflows when working with background tasks.
🔄 CLI Auto-Reload Features
New CLI Options:
⚡ Technical Implementation
📦 Installation
Requires the new extra for the dependency:
pip install 'procrastinate[reload]'🚀 Usage Examples
🎯 Development Workflow
🏗️ Implementation Details
🧪 Testing
This significantly improves the developer experience by eliminating manual worker restarts during development, similar to how works for web applications.
Addresses the need for faster development iteration when working with Procrastinate background tasks.