[Backgroundrb-devel] accessing session data in worker

Ezra Zygmuntowicz ezmobius at gmail.com
Tue Oct 17 13:12:15 EDT 2006


	Ahh ok I misunderstood you then. I thought you were trying to use  
session[:foo] from within a worker my bad.

-Ezra



On Oct 17, 2006, at 7:42 AM, Michael D'Auria wrote:

> I was accessing the Session model directly from within a worker and  
> it was working:
>
> class ClearSessionsWorker < BackgrounDRb::Rails
>
>   repeat_every 7.minutes
>   first_run Time.now
>
>   def do_work(args)
>     Session.destroy_all(["updated_at < ?", 20.minute.ago ])
>
>     ::BackgrounDRb::MiddleMan.instance.delete_worker @_job_key
>   end
> end
>
> I just wasn't cleaning the workers up properly, but it was cleaning  
> out sessions as it should...
>
>
> On 10/17/06, Bill Walton <bill.walton at charter.net> wrote: Hi Ezra,
>
> Ezra Zygmuntowicz wrote:
>
> > The session is not available in the workers.
>
> Thanks for clearing that up for me!  So the data 'inside' the  
> session record
> is not available, but the session record IS?  I'm using  
> BackgroundRB to do
> session cleanup for abandoned sessions.  I'm thinking that I can  
> pass the
> session id to the worker and then, inside the worker, retrieve and  
> delete
> that record with something like
>
> session_record = Session.find(:first, :conditions => ["sessid = ?",
> passed_in_session_id])
> session_record.destroy
>
> Is that right?  Or do I need to do something special to access that  
> record?
>
> Thanks,
> Bill
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel

-- Ezra Zygmuntowicz 
-- Lead Rails Evangelist
-- ez at engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)




More information about the Backgroundrb-devel mailing list