Skip to content

Commit

Permalink
Fix RedisClient::ConnectionError: stream closed in another thread
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalie committed May 26, 2023
1 parent faf5eef commit 50726df
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/travis/lock/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def self.clients
ttl: 5 * 60 * 1000,
retries: 5,
interval: 0.1,
timeout: 0.5
timeout: 0.5,
threads: 5
}

attr_reader :name, :config, :retried, :monitor
Expand All @@ -48,7 +49,12 @@ def exclusive

def client
monitor.synchronize do
self.class.clients[url] ||= Redlock::Client.new([url], redis_timeout: config[:timeout])
self.class.clients[url] ||= begin
redis_config = RedisClient.config(url: url)
pool = redis_config.new_pool(size: config[:threads])

Redlock::Client.new([pool], redis_timeout: config[:timeout])
end
end
end

Expand Down

0 comments on commit 50726df

Please sign in to comment.