Permalink
Browse files

upgrade to resque 0.10, fixes horrid Resque::Worker#work override

  • Loading branch information...
1 parent 189a5ac commit 03e4dec76b925e5f2862c25bf0ad7404591f8d2e @nevans nevans committed Aug 26, 2010
Showing with 8 additions and 56 deletions.
  1. +5 −5 Gemfile.lock
  2. +2 −46 lib/resque/pool/pooled_worker.rb
  3. +1 −5 resque-pool.gemspec
View
@@ -2,19 +2,19 @@ PATH
remote: .
specs:
resque-pool (0.0.9.dev)
- resque (= 1.9.10)
+ resque (~> 1.10)
GEM
remote: http://rubygems.org/
specs:
- json_pure (1.4.6)
+ json (1.4.6)
rack (1.2.1)
rake (0.8.7)
redis (2.0.5)
redis-namespace (0.8.0)
redis (< 3.0.0)
- resque (1.9.10)
- json_pure (~> 1.4.0)
+ resque (1.10.0)
+ json (~> 1.4.6)
redis-namespace (~> 0.8.0)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
@@ -29,6 +29,6 @@ PLATFORMS
DEPENDENCIES
rake
- resque (= 1.9.10)
+ resque (~> 1.10)
resque-pool!
rspec
@@ -11,55 +11,11 @@ def pool_master_has_gone_away?
@pool_master_pid && @pool_master_pid != Process.ppid
end
- # this allows us to shutdown
+ # override +shutdown?+ method
def shutdown?
- @shutdown || pool_master_has_gone_away?
+ super || pool_master_has_gone_away?
end
- # this entire method (except for one line) is copied and pasted from
- # resque-1.9.10. If shutdown were used as a method (attr_reader) rather
- # than an instance variable, I wouldn't need to reduplicate this. :-(
- #
- # hopefully I can get defunkt to accept my patch for this.
- # Until it is, the resque-pool gem will depend on an exact version of
- # resque.
- def work(interval = 5, &block)
- $0 = "resque: Starting"
- startup
-
- loop do
- #### THIS IS THE ONLY LINE THAT IS CHANGED
- break if shutdown?
- #### THAT WAS THE ONLY LINE THAT WAS CHANGED
-
- if not @paused and job = reserve
- log "got: #{job.inspect}"
- run_hook :before_fork, job
- working_on job
-
- if @child = fork
- rand # Reseeding
- procline "Forked #{@child} at #{Time.now.to_i}"
- Process.wait
- else
- procline "Processing #{job.queue} since #{Time.now.to_i}"
- perform(job, &block)
- exit! unless @cant_fork
- end
-
- done_working
- @child = nil
- else
- break if interval.to_i == 0
- log! "Sleeping for #{interval.to_i}"
- procline @paused ? "Paused" : "Waiting for #{@queues.join(',')}"
- sleep interval.to_i
- end
- end
-
- ensure
- unregister_worker
- end
end
end
View
@@ -17,11 +17,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec"
- # NOTE: we must depend on an explicit version of resque until the patch at
- # http://github.com/nevans/resque (or something similar) is accepted.
- # Until then, make sure that lib/resque/pool/pooled_worker.rb stays up to
- # date with Resque::Worker#work.
- s.add_dependency "resque", "=1.9.10"
+ s.add_dependency "resque", "~> 1.10"
s.files = Dir.glob("lib/**/*") +%w[README.md]
s.require_path = 'lib'

0 comments on commit 03e4dec

Please sign in to comment.