title: Timeout in a delayed job
body: <p>I have some code that potentially can run for a longer period of time. However if it does I want to kill it, here is what I'm doing at the moment :</p>
  
  <pre><code>def perform
      Timeout.timeout(ENV['JOB_TIMEOUT'].to_i, Exceptions::WorkerTimeout) { do_perform }
    end
  </code></pre>
  
  <p>private
    def do_perform
      ...some code...
    end</p>
  
  <p>Where <code>JOB_TIMEOUT</code> is an environment variable with value such as <code>10.seconds</code>. I've got reports that this still doesn't prevent my job from running longer that it should.</p>
  
  <p>Is there a better way to do this?</p>