Skip to content

Instantly share code, notes, and snippets.

@ShepFc3
Created June 24, 2011 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShepFc3/1045741 to your computer and use it in GitHub Desktop.
Save ShepFc3/1045741 to your computer and use it in GitHub Desktop.
def delayed_job
begin
Timeout::timeout(5) do
job = Delayed::Job.enqueue(HealthCheckJob.new)
queued = Delayed::Job.exists?(job)
Delayed::Worker.new.work_off if Rails.env == "test"
while queued == true
queued = Delayed::Job.uncached{ Delayed::Job.exists?(job) }
return true unless queued
sleep(1)
end
end
rescue Timeout::Error
return false
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment