# File lib/mongo/mongo_sharded_client.rb, line 136
    def checkout(&block)
      2.times do
        if connected?
          sync_refresh
        else
          connect
        end

        begin
          socket = block.call
        rescue => ex
          checkin(socket) if socket
          raise ex
        end

        if socket
          return socket
        else
          @connected = false
          #raise ConnectionFailure.new("Could not checkout a socket.")
        end
      end
    end