मैं एक समारोह है कि delayed_job द्वारा अतुल्यकालिक रूप से नियंत्रित किया जा करने के लिए चिह्नित किया गया है है:एक delayed_job करने के लिए एक ब्लॉक पासिंग
class CapJobs
def execute(params, id)
begin
unless Rails.env == "test"
Capistrano::CLI.parse(params).execute!
end
rescue
site = Site.find(id)
site.records.create!(:date => DateTime.now, :action => "Task Failure: #{params[0]}", :type => :failure)
site.save
ensure
yield id
end
end
handle_asynchronously :execute
end
जब मैं इस समारोह मैं एक ब्लॉक में पारित चलाएँ:
capjobs = CapJobs.new
capjobs.execute(parameters, @site.id) do |id|
asite = Site.find(id)
asite.records.create!(:date => DateTime.now, :action => "Created", :type => :init)
asite.status = "On Demo"
asite.dev = true
asite.save
end
यह काम करता है ठीक है जब बिना देरी के चलते चला जाता है * लेकिन जब मैं इसके साथ दौड़ता हूं तो मुझे निम्न त्रुटि मिलती है
2012-08-13T09:24:36-0300: [Worker(delayed_job host:eagle pid:12089)] SitesHelper::CapJobs#execute_without_delay failed with LocalJumpError: no block given (yield) - 0 failed attempts
2012-08-13T09:24:36-0300: [Worker(delayed_job host:eagle pid:12089)] PERMANENTLY removing SitesHelper::CapJobs#execute_without_delay because of 1 consecutive failures.
2012-08-13T09:24:36-0300: [Worker(delayed_job host:eagle pid:12089)] 1 jobs processed at 0.0572 j/s, 1 failed ...
ऐसा लगता है कि यह नहीं उठाया जाता है जिस ब्लॉक को पारित किया गया था। क्या यह करने का सही तरीका नहीं है या मुझे एक अलग विधि मिलनी चाहिए?
आप कृपया पोस्ट कर सकता कौन-सा कोड का इस्तेमाल किया? – brauliobo