File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff 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 } :#{ Process . pid } :#{ @queues . join ( ',' ) } "
456+ @to_s ||= "#{ hostname } :#{ pid } :#{ @queues . join ( ',' ) } "
457457 end
458458 alias_method :id , :to_s
459459
@@ -462,6 +462,11 @@ def hostname
462462 @hostname ||= `hostname` . chomp
463463 end
464464
465+ # Returns PID of running worker
466+ def pid
467+ @pid ||= Process . pid
468+ end
469+
465470 # Returns an array of string pids of all the other workers on this
466471 # machine. Useful when pruning dead workers on startup.
467472 def worker_pids
Original file line number Diff line number Diff line change 312312 workerA . work ( 0 )
313313 assert $AFTER_FORK_CALLED
314314 end
315+
316+ test "returns PID of running process" do
317+ assert_equal Process . pid , @worker . pid
318+ end
315319end
You can’t perform that action at this time.
0 commit comments