[Backgroundrb-devel] Strange behaviour (worker only running on 3 or more attempts)
hemant
gethemant at gmail.com
Thu Aug 14 22:24:10 EDT 2008
Hi,
>>> hemant wrote:
>>> I'm using Packet-0.1.10 and OS is ubuntu 8.04 and yep bdrb 1.0.4
>>>
>>
>> It shouldn't happen, I will check later today and reply.
>>
>
> Thanks very much Herman. I am using default config except for :log:
> foreground
>
I tried to reproduce the problem, But I couldn't, here is the code, I tried:
class WowWorker < BackgrounDRb::MetaWorker
set_worker_name :wow_worker
def create(args = nil)
# we are using memcache for storing results and hence, lets reset the cache
# memcache will persist the results between backgroundrb server restarts
end
def run_wow user_args
thread_pool.defer(:some_crap,user_args)
end
def some_crap user_args
# we are using memcache for storing results and hence, lets reset the cache.
# memcache will persist the results between backgroundrb server restarts
# Also, if you are running lots of tasks parallely, don't forget
to use unique keys
cache[:progress] = 0.00
5.times do |i|
sleep(2)
logger.info "starting some_crap #{i}"
cache[:progress] = ((i+1)/5.00)*100
end
end
end
# And I called using:
MiddleMan.worker(:wow_worker).async_run_wow(:arg => "hello world")
MiddleMan.worker(:wow_worker).ask_result(:progress)
So, I wonder, whats wrong there. You can send me a minimized version
of your application in tar ball and i will see, if I can reproduce the
problem.
Also, upgrade to git version if you haven't and don't use inbuilt
cache, try replacing it with memcache (again refer the docs).
More information about the Backgroundrb-devel
mailing list