New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
delayed_job with handle_asynchronously #428
Comments
Hello! I slightly edited formatting in your original post, because some return values were not showing up because of the What are your Airbrake, DelayedJob and Rails versions? |
rails (4.1.9) Airbrake.configure do |config| |
Judging by your examples, it's hard for me to see how Airbrake breaks DelayedJob for you. I tested it locally with simple examples and it works for me, with or without Airbrake. It looks like in your second example from IRB FWIW, from what I know, if you define I would suggest to run DelayedJob with |
i called but class of def process_pending_files
method = %{#{EXCHANGE_TYPES[exchange_type]}_#{PARSE_METHODS[parse_method]}}
logger.info "method: #{method}"
processor = self.send method if self.respond_to? method
logger.info "processor: #{processor} #{processor.class.to_s} #{processor.class}"
if processor.is_a?(Delayed::Backend::ActiveRecord::Job)
self.jobs << processor
save
end
end i get:
So aith Airbrake enabled, |
What's the source code of |
def import_1c
unless self.state == SpreeExchange::Transfer.state_code(:failure) or self.state == SpreeExchange::Transfer.state_code(:processed)
if self.state == SpreeExchange::Transfer.state_code(:pending)
self.state = SpreeExchange::Transfer.state_code :progress
save
end
Sunspot.session = Sunspot::Rails::StubSessionProxy.new(Sunspot.session)
something_processed = false
transfer_attachments.where(state: SpreeExchange::TransferAttachment.state_code(:pending)).where("file_file_name LIKE '%.xml'").order(:id).each do |attachment|
unless attachment.nil?
attachment.state = SpreeExchange::TransferAttachment.state_code(:progress)
attachment.save
base_filename = attachment.file_file_name.sub /\.xml$/i, ''
if STATES.values.include?(base_filename.to_sym)
self.state = SpreeExchange::Transfer.state_code base_filename.to_sym
save
end
node_set = Nokogiri::XML File.open attachment.file.path
begin
Spree::Product.import_1c node_set, transfer_attachments
attachment.state = SpreeExchange::TransferAttachment.state_code(:success)
attachment.save
if transfer_attachments.where("file_file_name LIKE '%.xml'").where.not(state: SpreeExchange::TransferAttachment.state_code(:success)).count == 0
self.state = SpreeExchange::Transfer.state_code :success
save
end
something_processed = true
rescue
attachment.state = SpreeExchange::TransferAttachment.state_code :failure
attachment.save
self.message = $!.message
self.exception_backtrace = $1.backtrace
self.state = SpreeExchange::Transfer.state_code :failure
save
end
end
end
Sunspot.session = Sunspot.session.original_session
Spree::Product.reindex_updated_after(created_at)
if something_processed and Delayed::Job.where('handler LIKE ?', '%update_yandex_market%').count < 2
self.update_yandex_market
end
end
end |
This method can return 2 values:
Sorry, but I fail to see how it can return a |
i wrote: def import_1c
#...
end
handle_asynchronously :import_1c, :queue => 'import', :run_at => Proc.new { Time.now.end_of_day - 7200 + Time.now.hour*60 + Time.now.min }
#... So when you executing method specified in |
i've made some research. |
Thanks, that's a very useful information! I'll investigate this later today. |
OK, I looked through commits between 4.1.0 and 4.0.0 and couldn't find anything relevant. How do you integrate Delayed Job with Airbrake? Could you show your |
A gentle ping. |
Hi
I have Tranfer model
method is import_1c
When i have no airbrake gem in Gemfile, everything is working, i have new job in delayed_jobs table after calling process_pending_files:
But after just installing airbrake, i get:
I can't even create record with .delay method:
There is nothing in delayed_jobs table
Any ideas?
The text was updated successfully, but these errors were encountered: