-
-
Save apeiros/6f139cf06ad36e023f46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PassthroughExceptions = [ | |
::NoMemoryError, | |
::SignalException, | |
::Interrupt, | |
::SystemExit, | |
] | |
def Thread.with_connection(*args) | |
start(*args) do |*inner_args| | |
begin | |
yield(*inner_args) | |
rescue *PassthroughExceptions | |
raise # do not handle PassthroughExceptions ourselves | |
rescue Exception => exception | |
ExceptionHandler.handle(exception) | |
ensure | |
ActiveRecord::Base.clear_active_connections! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment