Search code examples
rubysidekiq

How set timeout for jobs in sidekiq


I want to set timeout for jobs, meaning when a job has process time greater than timeout then that job will stop.

I have searched how to set global timeout config in file sidekiq.yml.

But I want to set separate timeout for difference separate jobs meaning one of classes to define worker will have particular timeout config.


Solution

  • There's no approved way to do this. You cannot stop a thread safely while it is executing. You need to change your job to check periodically if it should stop.

    You can set network timeouts on any 3rd party calls you are making so that they time out.