Sudden inexplicable active record connection timeouts while testing with RSPEC

删除回忆录丶 提交于 2019-12-05 17:47:49

It seems this is related to touching active record inside a spawned thread. It looks like the db connection doesn't get returned to the pool until it is reaped. I've been able to resolve this issue by explicitly asking for a connection ahead of time and closing it after I'm done. Try this:

Thread.new do
    ActiveRecord::Base.connection_pool.with_connection do |conn|
        UserMailer.accepted_parent_invitation_email(@parent_profile).deliver
    end
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!