Skip to content

Commit

Permalink
fix: thread pool scope and mutex need to be global across all instanc…
Browse files Browse the repository at this point in the history
…es of Scope for it to be a global thread pool (#471)
  • Loading branch information
MattFenelon authored Mar 22, 2024
1 parent 99f469f commit 51fb51c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/graphiti/scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 51fb51c

Please sign in to comment.