pythonapitasksidekiqluigi

scheduling a sidekiq job with a python script


I have Sidekiq running with a Rails app. I need to be able to run a job from a Python script (as I'm using Luigi to run tasks in general). I'm searching for a Python library to work with the Sidekiq API but so far no luck. Any ideas or thoughts on this?


Solution

  • https://github.com/mperham/sidekiq/wiki/FAQ#how-do-i-push-a-job-to-sidekiq-without-ruby

    This is the simplest Ruby, translate it to Python:

    require 'securerandom'
    require 'json'
    
    redis = Redis.new(:url => 'redis://hostname:port/db')
    msg = { "class" => 'MyWorker',
        "queue" => 'default',
        "args" => [1, 2, 3],
        'retry' => true,
        'jid' => SecureRandom.hex(12),
        'created_at' => Time.now.to_f,
        'enqueued_at' => Time.now.to_f }
    redis.lpush("queue:default", JSON.dump(msg))