Hi,
I have a long worker process I want to capture the output as dynamically
as possible and send it to the client. I do the following currently:
class SvnWorker < Worker::Base
def do_stuff(args)
tmp = []
my_project = args[:repo]
# Import the contents of a 20 Meg project into a bare bones svn repo.
import_status = `svn import #{path_to_extracted_zipdir}
file://#{my_project}`
tmp = import_status
results[:response] = tmp
end
def status
results[:response]
end
end
This only fills results[:response] at the end of the system call ... I
would rather dynamically get all the output to stdout the svn import
command gives back. Like the following (but doesnt work for some reason):
def do_stuff(args)
require ''open3''
tmp = []
my_project = args[:repo]
# Import the contents of a 20 Meg project into a bare bones svn repo.
Open3.popen3("svn import #{path_to_extracted_zipdir}
file://#{my_project}") do
|stdin,stdout,stderr|
while txt = stdout.gets
tmp << txt
results[:response] = tmp
end
end
end
But for a reason that eludes me I can''t seem to call open ever and if I
require anything in my worker class it crashes when I call that workers
do_work function. Any thoughts appreciated...
regards,
David G.