Skip to content

Commit f472191

Browse files
committed
chore: revert unnecessary changes from PR (debug logs, thread_pool_size, handle_thread_error)
1 parent 2ec85e1 commit f472191

1 file changed

Lines changed: 2 additions & 22 deletions

File tree

lib/delayed/worker.rb

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,40 +88,31 @@ def work_off(num = 100)
8888

8989
while total < num
9090
start = clock_time
91-
say "Attempting to reserve up to #{num - total} job(s)", 'debug'
9291
jobs = reserve_jobs
93-
say 'No jobs reserved; exiting work_off loop', 'debug' if jobs.empty?
9492
break if jobs.empty?
9593

9694
total += jobs.length
97-
say "Reserved #{jobs.length} job(s); dispatching batch", 'debug'
98-
pool = Concurrent::FixedThreadPool.new(thread_pool_size(jobs.length))
95+
pool = Concurrent::FixedThreadPool.new(jobs.length)
9996
jobs.each do |job|
100-
job_say job, 'Queued for thread execution', 'debug'
10197
pool.post do
102-
thread_started = false
10398
self.class.lifecycle.run_callbacks(:thread, self) do
104-
thread_started = true
10599
success.increment if perform(job)
106100
rescue DeserializationError => e
107101
handle_unrecoverable_error(job, e)
108102
rescue Exception => e # rubocop:disable Lint/RescueException
109103
handle_erroring_job(job, e)
110104
end
111105
rescue Exception => e # rubocop:disable Lint/RescueException
112-
handle_thread_error(job, e, thread_started)
106+
say "Job thread crashed with #{e.class.name}: #{e.message}", 'error'
113107
end
114108
end
115109

116-
say 'Waiting for worker threads to finish', 'debug'
117110
pool.shutdown
118111
pool.wait_for_termination
119-
say "Batch finished with #{success.value} successful job(s) out of #{total} attempted so far", 'debug'
120112

121113
break if stop? # leave if we're exiting
122114

123115
elapsed = clock_time - start
124-
say format('Batch elapsed %.4f seconds', elapsed), 'debug'
125116
interruptable_sleep(self.class.min_reserve_interval - elapsed)
126117
end
127118

@@ -244,17 +235,6 @@ def reload!
244235
Rails.application.reloader.reload! if defined?(Rails.application.reloader) && Rails.application.reloader.check!
245236
end
246237

247-
def thread_pool_size(job_count)
248-
return job_count unless Delayed::Job.respond_to?(:connection_pool)
249-
250-
pool_size = Delayed::Job.connection_pool.size
251-
return job_count unless pool_size
252-
253-
[job_count, [pool_size - 1, 1].max].min
254-
rescue StandardError
255-
job_count
256-
end
257-
258238
def clock_time
259239
Process.clock_gettime(Process::CLOCK_MONOTONIC)
260240
end

0 commit comments

Comments
 (0)