added activerecord concurrency to safe_fork
This commit is contained in:
parent
baa666610e
commit
a6847107ad
|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Nick Gauthier"]
|
s.authors = ["Nick Gauthier"]
|
||||||
s.date = %q{2010-04-11}
|
s.date = %q{2010-04-19}
|
||||||
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
s.description = %q{Spread your tests over multiple machines to test your code faster.}
|
||||||
s.email = %q{nick@smartlogicsolutions.com}
|
s.email = %q{nick@smartlogicsolutions.com}
|
||||||
s.extra_rdoc_files = [
|
s.extra_rdoc_files = [
|
||||||
|
@ -79,18 +79,18 @@ Gem::Specification.new do |s|
|
||||||
s.summary = %q{Distributed testing toolkit}
|
s.summary = %q{Distributed testing toolkit}
|
||||||
s.test_files = [
|
s.test_files = [
|
||||||
"test/pipe_test.rb",
|
"test/pipe_test.rb",
|
||||||
"test/test_helper.rb",
|
|
||||||
"test/ssh_test.rb",
|
"test/ssh_test.rb",
|
||||||
"test/message_test.rb",
|
|
||||||
"test/master_test.rb",
|
|
||||||
"test/fixtures/write_file.rb",
|
|
||||||
"test/fixtures/slow.rb",
|
|
||||||
"test/fixtures/write_file_spec.rb",
|
|
||||||
"test/fixtures/features/step_definitions.rb",
|
|
||||||
"test/fixtures/hello_world.rb",
|
|
||||||
"test/fixtures/write_file_alternate_spec.rb",
|
"test/fixtures/write_file_alternate_spec.rb",
|
||||||
"test/fixtures/sync_test.rb",
|
"test/fixtures/sync_test.rb",
|
||||||
|
"test/fixtures/hello_world.rb",
|
||||||
|
"test/fixtures/features/step_definitions.rb",
|
||||||
"test/fixtures/assert_true.rb",
|
"test/fixtures/assert_true.rb",
|
||||||
|
"test/fixtures/slow.rb",
|
||||||
|
"test/fixtures/write_file_spec.rb",
|
||||||
|
"test/fixtures/write_file.rb",
|
||||||
|
"test/message_test.rb",
|
||||||
|
"test/test_helper.rb",
|
||||||
|
"test/master_test.rb",
|
||||||
"test/runner_test.rb",
|
"test/runner_test.rb",
|
||||||
"test/worker_test.rb"
|
"test/worker_test.rb"
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,13 +2,13 @@ class SafeFork
|
||||||
def self.fork
|
def self.fork
|
||||||
begin
|
begin
|
||||||
# remove our connection so it doesn't get cloned
|
# remove our connection so it doesn't get cloned
|
||||||
ActiveRecord::Base.remove_connection if defined?(ActiveRecord)
|
connection = ActiveRecord::Base.remove_connection if defined?(ActiveRecord)
|
||||||
# fork a process
|
# fork a process
|
||||||
child = Process.fork do
|
child = Process.fork do
|
||||||
begin
|
begin
|
||||||
# create a new connection and perform the action
|
# create a new connection and perform the action
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
ActiveRecord::Base.establish_connection(connection.merge({:allow_concurrency => true})) if defined?(ActiveRecord)
|
||||||
rescue ActiveRecord::AdapterNotSpecified
|
rescue ActiveRecord::AdapterNotSpecified
|
||||||
# AR was defined but we didn't have a connection
|
# AR was defined but we didn't have a connection
|
||||||
end
|
end
|
||||||
|
@ -21,7 +21,7 @@ class SafeFork
|
||||||
ensure
|
ensure
|
||||||
# make sure we re-establish the connection before returning to the main instance
|
# make sure we re-establish the connection before returning to the main instance
|
||||||
begin
|
begin
|
||||||
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
ActiveRecord::Base.establish_connection(connection.merge({:allow_concurrency => true})) if defined?(ActiveRecord)
|
||||||
rescue ActiveRecord::AdapterNotSpecified
|
rescue ActiveRecord::AdapterNotSpecified
|
||||||
# AR was defined but we didn't have a connection
|
# AR was defined but we didn't have a connection
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue