Sudhi Kulkarni wrote: > Then in one of the periodic update methods if I access the > session[:executing] it is not updated to "done". Is there a problem if I > try to update session variable in a different thread?
Actually, this is precisely what I was trying to do in another thread here where Fred graciously helped me too. I'd advise NOT trying to use the session array Rails gives to you, but instead just telling the thread the sessionID, and ten doing all the session access yourself manually. That's what I'm doing. It's not TOO hard, although it inconveniently changes for Rails 2.2 vs. pre-Rails 2.2. See this: http://www.ruby-forum.com/topic/184782 And see if it makes any sense to you, or still seems worth it to you when you see what you must do. :) But it does seem to be working for me, with some basic unit tests. There's sadly one more added wrinkle with regard to race conditions when you start to deal with sessions like this, that can result in the main action over-writing the session data the thread tries to write, or vice-versa. I have a hacky way to minimize (although not totally eliminate that), that is Session-store agnostic. You can totally eliminate it if you're willing to hack the particular session store, as I believe Fred has also done for the AR store, but I think this is quickly getting beyond what you hoped would be an easy answer. But it is do-able, although not easy, I don't think you can get away with just trying to access the session array itself in a thread that's out of the request loop. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---