Search code examples
pythonruby-on-railsrubyqueuejobs

Queue Python background job from Rails server


I have a web frontend based on a Ruby On Rails app that inserts data into a Postgresql database. When the database gets new data it should be analyzed by using a Numpy/Scipy script. Is there an easy way to queue Python background jobs using Ruby?

One way I guess would be to use Resque (or some other Ruby job queuing system) to process a Ruby background script that again calls the Python script using the command line. Are there any other (better) alternatives?


Solution

  • Will sharing data with beanstalkd between Python and Ruby work for you ?

    Like

    #ruby
    insert into DB my-data
    put my-data onto shared-queue
    

    then

    #python 
    while True:
       take my-data from shared-queue 
       process my-data
       put did-process-data on shared-queue
    

    This would save Ruby calling Python or vice-versa but I'm unsure if you need transactional integrity etc.