lib/sequel/extensions/connection_expiration.rb in sequel-5.17.0 vs lib/sequel/extensions/connection_expiration.rb in sequel-5.18.0

- old
+ new

@@ -30,10 +30,11 @@ # module Sequel module ConnectionExpiration class Retry < Error; end + Sequel::Deprecation.deprecate_constant(self, :Retry) # The number of seconds that need to pass since # connection creation before expiring a connection. # Defaults to 14400 seconds (4 hours). attr_accessor :connection_expiration_timeout @@ -70,11 +71,12 @@ # When acquiring a connection, check if the connection is expired. # If it is expired, disconnect the connection, and retry with a new # connection. def acquire(*a) - begin + conn = nil + 1.times do if (conn = super) && (cet = sync{@connection_expiration_timestamps[conn]}) && Sequel.elapsed_seconds_since(cet[0]) > cet[1] if pool_type == :sharded_threaded @@ -82,13 +84,11 @@ else sync{@allocated.delete(Thread.current)} end disconnect_connection(conn) - raise Retry + redo end - rescue Retry - retry end conn end end