0

I want to run a python application in my Rails server with ActiveJob, but how can I transfer words that python application output to command line to around_perform in perform? I need to get result from the python application in around_perform.

  def perform(argument)
    cmd = "python3 " + argument + "/main.py "
    system cmd
  end

  private

  around_perform do |job, block|
    block.call
    puts "ActiveJob Done"
  end
Sree.Bh
  • 1,751
  • 2
  • 19
  • 25
PingChyi
  • 1
  • 1

1 Answers1

0

See the docs: https://api.rubyonrails.org/classes/ActiveJob/Callbacks/ClassMethods.html#method-i-around_perform

it's job.arguments or job.arguments.first in your case.

Siim Liiser
  • 3,860
  • 11
  • 13
  • I know that, but job.arguments refers to argument I pass into perform. And what I need are the words output by my python application:`system cmd` – PingChyi Jun 08 '20 at 10:36
  • See https://stackoverflow.com/questions/2232/how-to-call-shell-commands-from-ruby . You should not be using system if you want to access the output from your command. – Siim Liiser Jun 08 '20 at 11:14