File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -1048,9 +1048,7 @@ def request_setup req_or_uri # :nodoc:
10481048 # #shutdown when you are completely done making requests!
10491049
10501050 def shutdown
1051- @pool . available . shutdown do |http |
1052- http . finish
1053- end
1051+ @pool . shutdown { |http | http . finish }
10541052 end
10551053
10561054 ##
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ def initialize(options = {}, &block)
77 super
88
99 @available = Net ::HTTP ::Persistent ::TimedStackMulti . new ( @size , &block )
10- @key = : "current-#{ @available . object_id } "
10+ @key = "current-#{ @available . object_id } "
1111 end
1212
1313 def checkin net_http_args
14- stack = Thread . current [ @key ] [ net_http_args ]
14+ stack = Thread . current [ @key ] [ net_http_args ] ||= [ ]
1515
1616 raise ConnectionPool ::Error , 'no connections are checked out' if
1717 stack . empty?
@@ -26,8 +26,8 @@ def checkin net_http_args
2626 end
2727
2828 def checkout net_http_args
29- stacks = Thread . current [ @key ] ||= Hash . new { | h , k | h [ k ] = [ ] }
30- stack = stacks [ net_http_args ]
29+ stacks = Thread . current [ @key ] ||= { }
30+ stack = stacks [ net_http_args ] ||= [ ]
3131
3232 if stack . empty? then
3333 conn = @available . pop connection_args : net_http_args
@@ -40,6 +40,10 @@ def checkout net_http_args
4040 conn
4141 end
4242
43+ def shutdown
44+ Thread . current [ @key ] = nil
45+ super
46+ end
4347end
4448
4549require 'net/http/persistent/timed_stack_multi'
You can’t perform that action at this time.
0 commit comments