def self.fork
begin
connection = ActiveRecord::Base.remove_connection if defined?(ActiveRecord)
child = Process.fork do
begin
begin
ActiveRecord::Base.establish_connection((connection || {}).merge({:allow_concurrency => true})) if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
end
yield
ensure
ActiveRecord::Base.remove_connection if defined?(ActiveRecord)
end
end
ensure
begin
ActiveRecord::Base.establish_connection((connection || {}).merge({:allow_concurrency => true})) if defined?(ActiveRecord)
rescue ActiveRecord::AdapterNotSpecified
end
end
return child
end