Skip to content

Commit 67317e7

Browse files
morgothdefunkt
authored andcommitted
fixed actual pid of running worker
1 parent 3a48ade commit 67317e7

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/resque/worker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def inspect
453453
# The string representation is the same as the id for this worker
454454
# instance. Can be used with `Worker.find`.
455455
def to_s
456-
@to_s ||= "#{hostname}:#{pid}:#{@queues.join(',')}"
456+
@to_s ||= "#{hostname}:#{Process.pid}:#{@queues.join(',')}"
457457
end
458458
alias_method :id, :to_s
459459

@@ -464,7 +464,7 @@ def hostname
464464

465465
# Returns PID of running worker
466466
def pid
467-
@pid ||= Process.pid
467+
@pid ||= to_s.split(":")[1].to_i
468468
end
469469

470470
# Returns an array of string pids of all the other workers on this

test/worker_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,6 @@
314314
end
315315

316316
test "returns PID of running process" do
317-
assert_equal Process.pid, @worker.pid
317+
assert_equal @worker.to_s.split(":")[1].to_i, @worker.pid
318318
end
319319
end

0 commit comments

Comments
 (0)