[Backgroundrb-devel] ask_result usage

hemant kumar gethemant at gmail.com
Wed Sep 17 16:43:51 EDT 2008

Couple of things:

Are you using memcache for session storage? (please, consider using it,
if your rails app is already using memcache someway, its pretty cheap).
Also, only when you are using memcache for result storage, your results
will be available even if worker is processing some task, otherwise,
result will be only available at the end of task (or if you are using
thread pool).

On Wed, 2008-09-17 at 15:04 -0400, Mark Lynn wrote:
> I am new to Backgroundrb and am struggling to get a progress bar  
> working on a long running job. I have it setup with memcache which is  
> working. The code works when I check status using
>    MiddleMan.worker(:transfer_worker).ask_result(:percent_complete)
> However, things get messed up when I run a second instance of this  
> task and percent_complete is still 100% from the last run.

You need to reset the counter at the beginning of the task.

> So, I assume I need the ask_result version that uses the job_key so  
> that I am looking at a separate instance from the cache. I tried
>      result = MiddleMan.ask_result(:worker  
> => :transfer_worker, :job_key => job_key)
>      result[:percent_complete]
> which is similar to how ask_status was used in the Advanced Rails  
> Recipes book, but this gives
> undefined method `ask_result' for #<BackgrounDRb::ClusterConnection: 
> 0x1f496a0>

Error is obvious, you can't use ask_result like that. You need to go
through the worker proxy only.

More information about the Backgroundrb-devel mailing list