[Backgroundrb-devel] error message for record not found ?

Bill Walton bill.walton at charter.net
Tue Feb 20 15:48:27 EST 2007


I'm using backgroundrb for session management and deletion of visitor-entered information when a session is abandoned.  The visitor can either click a button to end their session and remove their data, or backgroundrb will do it for them after 5 minutes of inactivity.  

Everything's working fine, I think.  If the visitor explicitly logs out, then when the worker checks for their record it won't be there which will trigger logic that says 'you're done. close the connection and kill yourself'.  What makes me a little worried is that I'm getting what looks like an error message in backgroundrb.log.  I've included it below.  I've also included the worker code.  

Can anybody tell me how to verify that the worker is actually closing the connection and then creating suicide?  Versus dying because of this failed find and not closing the connection correctly?

Thanks,
Bill

----------- log message -----------
Couldn't find Emrec with ID=1 - (ActiveRecord::RecordNotFound)
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:955:in `find_one'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:941:in `find_from_ids'
C:/InstantRails-1.3/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:382:in `find'
./script/backgroundrb/../../config/../lib/workers/session_worker.rb:20:in `watch_session'
./script/backgroundrb/../../config/../lib/workers/session_worker.rb:12:in `do_work'
./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:36:in `start_process'
./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb_rails.rb:32:in `start_process'
./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:57:in `new_worker'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/thread.rb:135:in `synchronize'
./script/backgroundrb/../../config/../vendor/plugins/backgroundrb/backgroundrb.rb:49:in `new_worker'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1512:in `perform'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1578:in `main_loop'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1427:in `run'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1424:in `run'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1344:in `initialize'
C:/InstantRails-1.3/ruby/lib/ruby/1.8/drb/drb.rb:1624:in `start_service'
script/backgroundrb/start:108



------------ Worker code ----------
class SessionWorker < BackgrounDRb::Rails
 
  attr_reader :time_remaining
 
  def do_work(args)
    @time_remaining = args[:initial_setting].to_i
    @emrec_id = args[:emrec_id]
    @session_id = args[:session_id]    
    @session_rec = Session.find(:first,
                           :conditions => ["sessid = ?", @session_id])   
    watch_session(args)
    sleep(2)
    clean_up  
  end
    
  def watch_session(args)
    while @time_remaining > 0
      sleep(1)
      emrec = Emrec.find(@emrec_id)
      if emrec != nil
        if emrec.timer_suspended == 'no'
          last_activity = emrec.last_updated_at
          time_remaining_float = (last_activity + args[:initial_setting].to_i) - Time.now
          @time_remaining = time_remaining_float.to_i
        end
      else
        @time_remaining = 0
      end
    end
  end
  
  def clean_up
    emrec = Emrec.find(@emrec_id)
    if emrec != nil
      emrec.cleanup
      Session.delete(@session_rec.id)
    end
    ActiveRecord::Base.connection.disconnect!
    ::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key
  end

end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070220/abf58a04/attachment.html 


More information about the Backgroundrb-devel mailing list