Method: Sentry::ThreadedPeriodicWorker#ensure_thread

Defined in:
lib/sentry/threaded_periodic_worker.rb

#ensure_threadObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sentry/threaded_periodic_worker.rb', line 14

def ensure_thread
  return false if @exited
  return true if @thread&.alive?

  @thread = Thread.new do
    loop do
      sleep(@interval)
      run
    end
  end

  true
rescue ThreadError
  log_debug("[#{self.class.name}] thread creation failed")
  @exited = true
  false
end