Hi,
Newbie here. I've got a worker (for generating PDF reports) that
uses the "thread_pool" to allow processing multiple reports
simultaneously and queue up any requests that exceed the thread
pool (pool_size = 10 currently).
def process_pdf(user)
thread_pool.defer(user) do |user|
makepdf(user)
end
end
My question is: I use a mutex to handle synchronizing the
register_status. This works fine:
def makepdf(user)
txt = user.to_s + " started"
save_status(user, :progress, txt)
do_report(user)
txt = user.to_s + " ended"
save_status(user, :progress, txt)
end
def save_status(user_id,key,data)
@status_mutex.synchronize do
@worker_status[user_id] = { :key => key, :data => data}
end
register_status(@worker_status)
end
However, if more than 10 requests are submitted to the worker
at a time, those in excess of 10 are queued and thus never
get assigned a status in register_status. So, in my Rails/ajax
view, I have no "status" to display while the user waits.
I read that one shouldn't use the register_status inside the
thread_pool.defer block. Is there an alternate way to
show a "pending" status to requests that have been deferred
due to exceeding the thread pool?
Thanks,
Rog
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now._______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel