Forum: Ruby on Rails rails assumption about getting new thread on each request

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
buddycat (Guest)
on 2009-04-08 00:24
(Received via mailing list)
hi all,

i am wondering if there is consensus around whether it is an
assumption of the rails core that each request will be served by a
new, clean thread? i ask because i am using Thread.current hash and
while mongrel seems to handle each request with a new thread and so
Thread.current is clean, passenger serves the same thread each time.

besides my own selfish uses, this seems to be pertinent to several
places in rails core where Thread.current is set with ||=

lib/i18n.rb:40:      Thread.current[:locale] ||= default_locale
zones.rb:15:            Thread.current[:time_zone] || zone_default
Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup

so, what is the expected behavior for a webserver?
This topic is locked and can not be replied to.