File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
api/scpca_portal/management/commands Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ import logging
2+
3+ from django .core .management .base import BaseCommand
4+ from django .template .defaultfilters import pluralize
5+
6+ from scpca_portal .models import Job
7+
8+ logger = logging .getLogger ()
9+ logger .setLevel (logging .INFO )
10+ logger .addHandler (logging .StreamHandler ())
11+
12+
13+ class Command (BaseCommand ):
14+ help = """Pauses all processing jobs and adds them to the pending queue."""
15+
16+ def handle (self , * args , ** kwargs ):
17+ self .pause_processing ()
18+
19+ def pause_processing (self ):
20+ terminated_jobs = Job .terminate_processing (reason = "Processing paused on re-deploy." )
21+ retry_jobs = Job .create_retry_jobs (terminated_jobs )
22+
23+ retry_job_count = len (retry_jobs )
24+ logger .info (
25+ f"{ retry_job_count } processing job{ pluralize (retry_job_count )} were paused "
26+ "and added to the pending queue before deploy."
27+ )
You can’t perform that action at this time.
0 commit comments