-
Notifications
You must be signed in to change notification settings - Fork 0
Scheduler fixes #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduler fixes #27
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses scheduler reliability issues by improving logging, preventing duplicate job schedules, and enhancing error handling for backup job scheduling.
- Enhanced logging throughout the scheduler initialization and job scheduling processes
- Added guards to prevent duplicate scheduler initialization using a global flag
- Improved job cleanup and verification with better error messages
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| from datetime import datetime # Import to ensure availability | ||
|
|
Copilot
AI
Sep 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant import - datetime is already imported at line 2. This duplicate import should be removed.
| from datetime import datetime # Import to ensure availability | |
| def backup_with_context(): | ||
| from datetime import datetime, timedelta # Import inside function for closure scope | ||
|
|
||
| with app.app_context(): |
Copilot
AI
Sep 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant import - both datetime and timedelta are already imported at line 2. This duplicate import should be removed.
| def backup_with_context(): | |
| from datetime import datetime, timedelta # Import inside function for closure scope | |
| with app.app_context(): | |
| def backup_with_context(): | |
| with app.app_context(): |
| logger.info("Scheduler initialization at startup completed") | ||
| except Exception as e: | ||
| logger.error(f"Failed to initialize scheduler at startup: {e}") | ||
| if not globals().get('_scheduler_startup_completed', False): |
Copilot
AI
Sep 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using globals() for state management is an anti-pattern. Consider using a module-level variable instead, similar to how _scheduler_initialized is handled elsewhere in the code.
| for job in backup_jobs: | ||
| logger.info(f"Scheduled job: {job.id} -> next run: {job.next_run_time}") | ||
|
|
||
| globals()['_scheduler_startup_completed'] = True |
Copilot
AI
Sep 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using globals() for state management is an anti-pattern. Consider using a module-level variable instead, similar to how _scheduler_initialized is handled elsewhere in the code.
| import traceback | ||
| logger.error(f"Traceback: {traceback.format_exc()}") | ||
| else: | ||
| logger.info("Scheduler startup initialization skipped - already completed") |
Copilot
AI
Sep 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using globals() for state management is an anti-pattern. Consider using a module-level variable instead, similar to how _scheduler_initialized is handled elsewhere in the code.
No description provided.