79 lines
2.9 KiB
Python
Executable File
79 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Inspect current APScheduler jobs (active and scheduled).
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
from datetime import datetime
|
|
|
|
# Add project root to path
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
|
|
|
|
from scipaperloader import create_app
|
|
from scipaperloader.models import ScraperState
|
|
|
|
def main():
|
|
print("=== APScheduler Task Inspector ===")
|
|
print(f"Time: {datetime.now()}\n")
|
|
|
|
app = create_app()
|
|
|
|
with app.app_context():
|
|
# Check scraper state
|
|
scraper_state = ScraperState.get_current_state()
|
|
print(f"🔄 Scraper State:")
|
|
print(f" Active: {'✅' if scraper_state.is_active else '❌'} {scraper_state.is_active}")
|
|
print(f" Paused: {'⏸️' if scraper_state.is_paused else '▶️'} {scraper_state.is_paused}")
|
|
print()
|
|
|
|
# Check APScheduler
|
|
scheduler = app.config.get('SCHEDULER')
|
|
if not scheduler:
|
|
print("❌ APScheduler not found in app config")
|
|
return
|
|
|
|
print("📋 APScheduler Status:")
|
|
# Access the underlying scheduler
|
|
if hasattr(scheduler, 'scheduler') and scheduler.scheduler:
|
|
print(f" Running: {'✅' if scheduler.scheduler.running else '❌'} {scheduler.scheduler.running}")
|
|
else:
|
|
print("❌ APScheduler instance not accessible")
|
|
print()
|
|
|
|
# Get all jobs
|
|
if hasattr(scheduler, 'scheduler') and scheduler.scheduler:
|
|
all_jobs = scheduler.scheduler.get_jobs()
|
|
else:
|
|
all_jobs = []
|
|
paper_jobs = scheduler.get_paper_jobs()
|
|
|
|
print(f"📊 Job Statistics:")
|
|
print(f" Total jobs: {len(all_jobs)}")
|
|
print(f" Paper processing jobs: {len(paper_jobs)}")
|
|
print()
|
|
|
|
if paper_jobs:
|
|
print("📝 Active Paper Processing Jobs:")
|
|
for job in paper_jobs:
|
|
next_run = job.get('next_run_time', 'Not scheduled')
|
|
print(f" • {job['id']}")
|
|
print(f" Next run: {next_run}")
|
|
print(f" Name: {job.get('name', 'N/A')}")
|
|
if job.get('args'):
|
|
print(f" Paper ID: {job['args'][0] if job['args'] else 'N/A'}")
|
|
print()
|
|
else:
|
|
print("✅ No active paper processing jobs")
|
|
|
|
# Show other jobs if any
|
|
other_jobs = [job for job in all_jobs if not any(pattern in job.id for pattern in ['paper_process_', 'test_paper_process_', 'process_paper_'])]
|
|
if other_jobs:
|
|
print(f"🔧 Other Scheduled Jobs ({len(other_jobs)}):")
|
|
for job in other_jobs:
|
|
next_run = job.next_run_time.strftime('%Y-%m-%d %H:%M:%S') if job.next_run_time else 'Not scheduled'
|
|
print(f" • {job.id} - Next run: {next_run}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|