Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/async/http/faraday/clients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
require "async/http/client"
require "async/http/proxy"

::Thread.attr_accessor :async_http_faraday_per_thread_persistent_client

module Async
module HTTP
module Faraday
Expand Down Expand Up @@ -177,10 +179,10 @@ def with_proxied_client(proxy_endpoint, endpoint, &block)
# This will close all clients associated with all threads.
def close
Thread.list.each do |thread|
if clients = thread[@key]
if clients = thread.async_http_faraday_per_thread_persistent_client
clients.close

thread[@key] = nil
thread.async_http_faraday_per_thread_persistent_client = nil
end
end
end
Expand All @@ -192,9 +194,7 @@ def make_clients
end

def clients
thread = Thread.current

return thread.thread_variable_get(@key) || thread.thread_variable_set(@key, make_clients)
Thread.current.async_http_faraday_per_thread_persistent_client ||= make_clients
end
end
end
Expand Down