Add more debugging prints for job creation, saving, loading, and processing

- Add try-except in save_jobs to catch errors
- Print job IDs when loading jobs in /jobs route
- Print timestamp when job is created
- Print start/end times for processing
- Print successful save confirmation
This commit is contained in:
nmemmert committed 2025-11-05 15:45:18 -05:00
1 parent 92919585a2
commit c60d6673db
1 file changed
+11 -5
+11 -5
View File
@@ -337,8 +337,12 @@ def load_jobs():
def save_jobs(jobs):
"""Save jobs to JSON file."""
print(f"Saving {len(jobs)} jobs to {JOBS_FILE}")
with open(JOBS_FILE, 'w') as f:
json.dump(jobs, f, indent=2, default=str)
try:
with open(JOBS_FILE, 'w') as f:
json.dump(jobs, f, indent=2, default=str)
print(f"Successfully saved {len(jobs)} jobs")
except Exception as e:
print(f"Error saving jobs: {e}")
@app.route('/', methods=['GET', 'POST'])
@login_required
@@ -392,7 +396,7 @@ def index():
'progress': 0
}
save_jobs(jobs)
print(f"Job {job_id} created and saved")
print(f"Job {job_id} created and saved at {job_start_time}")
# Start processing in background
processing_complete = False
@@ -432,9 +436,10 @@ def results():
@login_required
def jobs():
jobs = load_jobs()
print(f"Loaded {len(jobs)} jobs")
print(f"Loaded {len(jobs)} jobs: {list(jobs.keys())}")
# Sort jobs by timestamp, newest first
sorted_jobs = sorted(jobs.values(), key=lambda x: str(x.get('timestamp', '')), reverse=True)
print(f"Sorted jobs: {[j.get('id', 'no-id') for j in sorted_jobs[:5]]}") # First 5
return render_template('jobs.html', jobs=sorted_jobs, user_info=get_user_info())
@app.route('/job/<job_id>')
@@ -676,7 +681,7 @@ def process_pdfs(pdfdir, outputfolder, job_id=None):
def process_pdfs_async(pdfdir, outputfolder, job_id):
global processing_complete
print(f"Processing started for job {job_id}")
print(f"Processing started for job {job_id} at {datetime.now()}")
try:
jobs = load_jobs()
if job_id not in jobs:
@@ -922,6 +927,7 @@ def process_pdfs_async(pdfdir, outputfolder, job_id):
jobs[job_id]['message'] = msg
save_jobs(jobs)
processing_complete = True # Still mark as complete to allow retry
print(f"Processing finished for job {job_id} at {datetime.now()}")
@app.route('/download/<job_id>')
@login_required