Skip to content

Commit

Permalink
Extract forking stuff
Browse files Browse the repository at this point in the history
This method now makes sure that @child_pid is dealt with entirely inside its
scope, which is nice.
  • Loading branch information
steveklabnik committed Apr 28, 2013
1 parent 063c69c commit 22e18a8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/resque/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ def process_job(job, &block)

worker_registry.working_on self, job

fork_for_child(job, &block)

ensure
done_working
end

def fork_for_child(job, &block)
@child_pid = fork(job) do
reconnect
run_hook :after_fork, job
Expand All @@ -483,7 +490,6 @@ def process_job(job, &block)
else
perform(job, &block)
end
done_working
ensure
@child_pid = nil
end
Expand Down

0 comments on commit 22e18a8

Please sign in to comment.