Skip to content

Instantly share code, notes, and snippets.

@vpamulap
Created April 4, 2012 18:58
Show Gist options
  • Save vpamulap/2304749 to your computer and use it in GitHub Desktop.
Save vpamulap/2304749 to your computer and use it in GitHub Desktop.
Resque Status Hash Problem
Added in gemfile:
gem 'resque-status'
My Initializer: resque.rb
require 'resque/job_with_status'
Resque.redis = 'localhost:6379'
Resque::Plugins::Status::Hash.expire_in = (24 * 60 * 60)
________________________________________________
Job:
class Myjob
include Resque::Plugins::Status
def perform
puts status.inspect
status["a"] = "b"
status["c"] = "d"
puts status.inspect
sleep(5)
puts status.inspect
end
end
_________________________________________
Job called in action:
jobid = Myjob.create().to_s
_________________________________________
Worker Output:
#<Resque::Plugins::Status::Hash {"time"=>1333566122, "status"=>"working", "uuid"=>"961f51e060b6012f1d90388d122a27ec", "options"=>{}, "name"=>"Myjob()"}>
#<Resque::Plugins::Status::Hash {"time"=>1333566122, "status"=>"working", "uuid"=>"961f51e060b6012f1d90388d122a27ec", "options"=>{}, "name"=>"Myjob()"}>
#<Resque::Plugins::Status::Hash {"time"=>1333566122, "status"=>"working", "uuid"=>"961f51e060b6012f1d90388d122a27ec", "options"=>{}, "name"=>"Myjob()"}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment