Skip to content

Commit

Permalink
Merge pull request #31 from mlibrary/term-fetcher-concurrency-bug
Browse files Browse the repository at this point in the history
Fix concurrency Bug
  • Loading branch information
niquerio authored Jul 26, 2024
2 parents c8e75de + c88b9c3 commit 0112f2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 7 additions & 7 deletions lib/authority_browse/term_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ def load_batch(batch)
end
end

# @retrun Concurrent::ThreadPoolExecutor
# @retrun Concurrent::FixedThreadPool
def pool
@pool ||= Concurrent::ThreadPoolExecutor.new(
min_threads: @threads,
max_threads: @threads,
max_queue: 200,
fallback_policy: :caller_runs
)
@pool ||= Concurrent::FixedThreadPool.new(@threads,
# max_queue: 0 means unlimited items in the queue. This is so we don't lose any
# work when shutting down.
max_queue: 0,
# fallback_policy is probably unnessary here but it won't hurt to set is explictly
fallback_policy: :caller_runs)
end

# Fetch all of the facets and load them into the :_from_biblio table
Expand Down
5 changes: 4 additions & 1 deletion lib/call_number_browse/term_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ def initialize(page_size: 10_000, threads: 4)
# @return Concurrent::FixedThreadPool
def pool
@pool ||= Concurrent::FixedThreadPool.new(@threads,
max_queue: 200,
# max_queue: 0 means unlimited items in the queue. This is so we don't lose any
# work when shutting down.
max_queue: 0,
# fallback_policy is probably unnessary here but it won't hurt to set is explictly
fallback_policy: :caller_runs)
end

Expand Down

0 comments on commit 0112f2b

Please sign in to comment.