# File lib/moped/node.rb, line 113 def connection connection_acquired = false begin pool.with do |conn| connection_acquired = true yield(conn) end rescue Timeout::Error, ConnectionPool::PoolShuttingDownError => e if e.kind_of?(ConnectionPool::PoolShuttingDownError) @pool = nil Connection::Manager.delete_pool(self) raise Errors::PoolTimeout.new(e) end raise connection_acquired ? e : Errors::PoolTimeout.new(e) end end