Skip to content

Commit 51fb51c

Browse files
authored
fix: thread pool scope and mutex need to be global across all instances of Scope for it to be a global thread pool (#471)
1 parent 99f469f commit 51fb51c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/graphiti/scope.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ class Scope
33
attr_accessor :object, :unpaginated_object
44
attr_reader :pagination
55

6-
@thread_pool_executor_mutex = Mutex.new
6+
@@thread_pool_executor_mutex = Mutex.new
77

88
def self.thread_pool_executor
99
return @thread_pool_executor if @thread_pool_executor
1010

1111
concurrency = Graphiti.config.concurrency_max_threads || 4
12-
@thread_pool_executor ||= @thread_pool_executor_mutex.synchronize do
13-
Concurrent::ThreadPoolExecutor.new(
12+
@@thread_pool_executor_mutex.synchronize do
13+
@@thread_pool_executor ||= Concurrent::ThreadPoolExecutor.new(
1414
min_threads: 0,
1515
max_threads: concurrency,
1616
max_queue: concurrency * 4,

0 commit comments

Comments
 (0)