Skip to content

Commit

Permalink
Use Rails executor instead of reloader when wrapping inline execution (
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Jan 23, 2024
1 parent eec1f4b commit c8c2dd2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/models/good_job/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def enqueue(active_jobs = [], **properties, &block)

active_jobs = add(active_jobs, &block)

Rails.application.reloader.wrap do
Rails.application.executor.wrap do
record.with_advisory_lock(function: "pg_advisory_lock") do
record.update!(enqueued_at: Time.current)

Expand Down
2 changes: 1 addition & 1 deletion lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def self.perform_inline(queue_string = "*", limit: nil)
loop do
break if limit && iteration >= limit

result = Rails.application.reloader.wrap { job_performer.next }
result = Rails.application.executor.wrap { job_performer.next }
break unless result
raise result.unhandled_error if result.unhandled_error

Expand Down
4 changes: 2 additions & 2 deletions lib/good_job/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def enqueue_all(active_jobs)
active_jobs = Array(active_jobs)
return 0 if active_jobs.empty?

Rails.application.reloader.wrap do
Rails.application.executor.wrap do
current_time = Time.current
executions = active_jobs.map do |active_job|
GoodJob::Execution.build_for_enqueue(active_job).tap do |execution|
Expand Down Expand Up @@ -139,7 +139,7 @@ def enqueue_at(active_job, timestamp)
# job there to be enqueued using enqueue_all
return if GoodJob::Bulk.capture(active_job, queue_adapter: self)

Rails.application.reloader.wrap do
Rails.application.executor.wrap do
will_execute_inline = execute_inline? && (scheduled_at.nil? || scheduled_at <= Time.current)
execution = GoodJob::Execution.enqueue(
active_job,
Expand Down

0 comments on commit c8c2dd2

Please sign in to comment.