To enable multithreading in rails I have set config.threadsafe!
in development.rb
.
I get an error saying:
'method_missing': undefined method `threadsafe!' (NoMethodError)
I am using rails 4.1.1 and ruby 2.0.0. Please anyone help me with reason and way to come out of this.
development.rb
:
Rails.application.configure do
config.cache_classes = false
config.threadsafe!
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = false
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.raise_runtime_errors = true
end
Error:
/home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined
method `threadsafe!' for #<Rails::Application::Configuration:0x0000000482a6c8> (NoMethodError)
from /home/gayithri/workspace/ThreadDemo/config/environments/development.rb:8:in `block in <top (required)>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/railtie.rb:210:in `instance_eval'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/railtie.rb:210:in `configure'
from /home/gayithri/workspace/ThreadDemo/config/environments/development.rb:1:in `<top (required)>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/engine.rb:594:in `block (2 levels) in <class:Engine>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/engine.rb:593:in `each'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/engine.rb:593:in `block in <class:Engine>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:30:in `run'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:44:in `each'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:44:in `tsort_each_child'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `call'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /home/gayithri/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/application.rb:288:in `initialize!'
from /home/gayithri/workspace/ThreadDemo/config/environment.rb:5:in `<top (required)>'
from /home/gayithri/workspace/ThreadDemo/config.ru:3:in `require'
from /home/gayithri/workspace/ThreadDemo/config.ru:3:in `block in <main>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /home/gayithri/workspace/ThreadDemo/config.ru:in `new'
from /home/gayithri/workspace/ThreadDemo/config.ru:in `<main>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/server.rb:50:in `app'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/server.rb:130:in `log_to_stdout'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/server.rb:67:in `start'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:81:in `block in server'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
from /home/gayithri/workspace/ThreadDemo/bin/rails:8:in `require'
from /home/gayithri/workspace/ThreadDemo/bin/rails:8:in `<top (required)>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `load'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/rails.rb:27:in `call'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /home/gayithri/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /home/gayithri/workspace/ThreadDemo/bin/spring:16:in `require'
from /home/gayithri/workspace/ThreadDemo/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
config.threadsafe!
is no longer necessary and was removed. Rails is threadsafe by default. All it did on this config option turned out to be also valid for multiprocess single threaded deployment, so now it just does this operations.
Removing config.threadsafe!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With