Skip to content

Commit

Permalink
fixed actual pid of running worker
Browse files Browse the repository at this point in the history
  • Loading branch information
morgoth authored and defunkt committed Mar 4, 2011
1 parent 3a48ade commit 67317e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/resque/worker.rb
Expand Up @@ -453,7 +453,7 @@ def inspect
# The string representation is the same as the id for this worker
# instance. Can be used with `Worker.find`.
def to_s
@to_s ||= "#{hostname}:#{pid}:#{@queues.join(',')}"
@to_s ||= "#{hostname}:#{Process.pid}:#{@queues.join(',')}"
end
alias_method :id, :to_s

Expand All @@ -464,7 +464,7 @@ def hostname

# Returns PID of running worker
def pid
@pid ||= Process.pid
@pid ||= to_s.split(":")[1].to_i
end

# Returns an array of string pids of all the other workers on this
Expand Down
2 changes: 1 addition & 1 deletion test/worker_test.rb
Expand Up @@ -314,6 +314,6 @@
end

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

0 comments on commit 67317e7

Please sign in to comment.