lib/rufus/jig/adapters/patron.rb in rufus-jig-0.1.16 vs lib/rufus/jig/adapters/patron.rb in rufus-jig-0.1.17
- old
+ new
@@ -44,52 +44,36 @@
def close
# it's not really closing, it's rather making sure the patron
# session can get collected as garbage
- Thread.current[key] = nil
+ #Thread.current[key] = nil
end
def variant
:patron
end
protected
- def key
- self.object_id.to_s
- end
-
- # One patron session per thread
- #
def get_patron (opts)
to = (opts[:timeout] || @options[:timeout])
to = to.to_i if to
to = nil if to && to < 1
- k = key
+ patron = Patron::Session.new
+ patron.base_url = "#{@host}:#{@port}"
- patron = Thread.current[k]
-
- return patron if patron && patron.timeout == to
-
- if patron.nil?
- patron = Patron::Session.new
- patron.base_url = "#{@host}:#{@port}"
- end
-
#patron.connect_timeout = 1
# connection timeout defaults to 1 second
patron.timeout = to
patron.headers['User-Agent'] =
@options[:user_agent] ||
- [
- self.class, Rufus::Jig::VERSION, Thread.current.object_id, '(patron)'
- ].join(' ')
+ [ self.class, Rufus::Jig::VERSION, '(patron)' ].join(' ')
- Thread.current[k] = patron
+ patron
end
def do_request (method, path, data, opts)
opts['Expect'] = '' if (method == :put) && ( ! @options[:expect])