Skip to content

Commit 56ad1e7

Browse files
quirkeydefunkt
authored andcommitted
Assign the job's worker before calling before_fork
Useful for inspecting the jobs woker in the hook
1 parent 4499a39 commit 56ad1e7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/resque/worker.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def work(interval = 5.0, &block)
128128

129129
if not paused? and job = reserve
130130
log "got: #{job.inspect}"
131+
job.worker = self
131132
run_hook :before_fork, job
132133
working_on job
133134

@@ -160,6 +161,7 @@ def work(interval = 5.0, &block)
160161
def process(job = nil, &block)
161162
return unless job ||= reserve
162163

164+
job.worker = self
163165
working_on job
164166
perform(job, &block)
165167
ensure
@@ -388,7 +390,6 @@ def unregister_worker
388390
# Given a job, tells Redis we're working on it. Useful for seeing
389391
# what workers are doing and when.
390392
def working_on(job)
391-
job.worker = self
392393
data = encode \
393394
:queue => job.queue,
394395
:run_at => Time.now.strftime("%Y/%m/%d %H:%M:%S %Z"),

0 commit comments

Comments
 (0)