10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/async_experiments/candidate_worker.rb', line 10
def experiment_candidate(experiment_config)
experiment = experiment_config.symbolize_keys
start_time = Time.now
run_output = yield
duration = (Time.now - start_time).to_f
ExperimentResultWorker.perform_async(experiment[:name], experiment[:id], run_output, duration, :candidate)
run_output
rescue StandardError => exception
if ENV["RAISE_EXPERIMENT_ERRORS"]
raise exception
else
backtrace = exception.backtrace
backtrace.unshift(exception.inspect)
ExperimentErrorWorker.perform_async(experiment[:name], backtrace.join("\n"))
end
end
|