Dear Mailing List,
I am trying to use backgroundRB to process an uploaded CSV file and save
it in the database. I have successfully done this, with only one problem
that seems very unusual. After starting the server, it takes three tries
before my script is run.
For example, in my controller I have the code:
def authenticate_import
@dataset = Dataset.new params[:dataset]
@dataset.campaign = @campaign
#Check the normal info is valid
if [EMAIL PROTECTED]
render :action => 'import'
else
#Start the worker
MiddleMan.worker(:dataset_worker).async_process(:arg =>
@dataset)
@progress =
MiddleMan.worker(:dataset_worker).ask_result(:progress)
render :action => 'progress'
end
end
This progress is then fed into a progress bar which periodically updates
itself by calling:
@progress = MiddleMan.worker(:dataset_worker).ask_result(:progress)
The problem is that the first two times I attempt uploading (.i.e
calling this code) nothing happens. No output happens at all. After that
every call works fine and all the debugging info etc is written to the
log files etc, everything is saved fine.
Does anyone have any ideas why this may be happening? any help would be
greatly appreciated
My worker is below:
class DatasetWorker < BackgrounDRb::MetaWorker
set_worker_name :dataset_worker
def create(args = nil)
logger.info "Dataset Worker setup"
end
def process(dataset)
thread_pool.defer(:process_csv, dataset)
end
def process_csv(dataset)
logger.info "Started to Process Dataset (title: #{dataset.name})"
cache[:progress] = 0.00
.
. #Code to save stuff into database and updating cache[:progress]
.
end
end
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel