Displaying 2 results from an estimated 2 matches for "save_status".
Did you mean:
saved_status
2007 Dec 19
6
thread_pooling sleeping
...Rb::MetaWorker
set_worker_name :foo_worker
def create(args=nil)
@mutex = Mutex.new
@mutex.synchronize do
@statuses = {}
register_status(@statuses)
end
end
def do_task(some_user_id)
thread_pool.defer(some_user_id) do |user_id|
user = User.find user_id
save_status user_id, :progress, "Starting Task"
user.do_some_database_stuff
save_status user_id, :progress, "Task Stage 2"
user.do_some_other_database_stuff
save_status user_id, :progress, "Task Stage 3"
save_status user_id, :completed, true
end...
2008 May 09
1
register_status for excess thread_pool?
...ool (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_...