Any method to check if a task is running?
Pablo-Merino opened this issue · 4 comments
Hey! Is there any method to check if my task is running? For example, I have this task:
SHARE_UPDATER_QUEUE = GirlFriday::WorkQueue.new(:share_updater, :size => 7) do |msg|
Company.update_shares
end
Is there any way I can know (from my model's update_share
method) if SHARE_UPDATER_QUEUE
is running? Or wait until a task is done to continue processing the rest of the queue?
You can define a callback which is called when a task has completed.
SHARE_UPDATER_QUEUE.push(:some => 'args') do |result|
# result = result of the last expression in your msg block
end
You can also get GirlFriday.status
. But in general, no, there's no easy way to determine runtime status for a queue; performing logic based on that would be full of race conditions.
Thanks for the quick response! I'll just rethink the entire thing so I don't need to check the status 😄
I didn't think the callback was available unless you are using the in-memory store?
Yep, that's true.