From d89e5875b34436fde50a36d99f7ff10ccaceefad Mon Sep 17 00:00:00 2001 From: Matt Fenelon Date: Fri, 22 Mar 2024 13:24:49 +0000 Subject: [PATCH] fix: thread pool scope and mutex need to be global across all instances of Scope for it to be a global thread pool (#471) --- lib/graphiti/scope.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/graphiti/scope.rb b/lib/graphiti/scope.rb index 8f8102ee..6c7ac272 100644 --- a/lib/graphiti/scope.rb +++ b/lib/graphiti/scope.rb @@ -3,14 +3,14 @@ class Scope attr_accessor :object, :unpaginated_object attr_reader :pagination - @thread_pool_executor_mutex = Mutex.new + @@thread_pool_executor_mutex = Mutex.new def self.thread_pool_executor return @thread_pool_executor if @thread_pool_executor concurrency = Graphiti.config.concurrency_max_threads || 4 - @thread_pool_executor ||= @thread_pool_executor_mutex.synchronize do - Concurrent::ThreadPoolExecutor.new( + @@thread_pool_executor_mutex.synchronize do + @@thread_pool_executor ||= Concurrent::ThreadPoolExecutor.new( min_threads: 0, max_threads: concurrency, max_queue: concurrency * 4,