Skip to content

Commit 5a88fa7

Browse files
committed
Add current_job attribute to Worker
1 parent 305d9f4 commit 5a88fa7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

django_dbq/management/commands/worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(self, name, rate_limit_in_seconds):
2020
self.rate_limit_in_seconds = rate_limit_in_seconds
2121
self.alive = True
2222
self.last_job_finished = None
23+
self.current_job = None
2324
self.init_signals()
2425

2526
def init_signals(self):
@@ -63,6 +64,7 @@ def _process_job(self):
6364
)
6465
job.state = Job.STATES.PROCESSING
6566
job.save()
67+
self.current_job = job
6668

6769
try:
6870
task_function = import_string(job.next_task)
@@ -100,6 +102,8 @@ def _process_job(self):
100102
logger.exception("Failed to save job: id=%s", job.pk)
101103
raise
102104

105+
self.current_job = None
106+
103107

104108
class Command(BaseCommand):
105109

0 commit comments

Comments
 (0)