From: THAKUR PRASHANT SINGH on
Thanks for help I think I got the issue solved.
file = File.open("kml/#{@file_names[file_index]}","w")
file.write(@kml_file_data.to_xml)
file.close
The last line was missing. When I closed the file the problem
disappeared

-----Original Message-----
From: THAKUR PRASHANT SINGH
Sent: Friday, February 26, 2010 4:48 PM
To: ruby-talk ML
Subject: Re: Class Function call vs Normal Function call

Hi Brain,
I have tried to create a test application with code like

zip_file= ZipUtils.new('FILE_0.kml')
zip_file.createkmzfile
this works fine.
The problem comes which I think is when we have very high CPU usage in
my case it was 50% i.e. in dual processor machine a processor was
completely occupied.
Can this be a reason ?
The test scenario can be load the CPU in program and then execute these
lines when utilization reaches these levels.
I got a similar issue when I was using REXML which got corrected when I
switched to Nokogiri..
Any other pointers ??
Regards,
Prashant

-----Original Message-----
From: b.candler(a)pobox.com [mailto:b.candler(a)pobox.com]
Sent: Friday, February 26, 2010 4:36 PM
To: ruby-talk ML
Subject: Re: Class Function call vs Normal Function call

THAKUR PRASHANT SINGH wrote:
> The first piece of code is called as lines below from another class
> zip_file= ZipUtils.new(@file_names[file_index])
> zip_file.createkmzfile

That's no good. As I said, you need to create two separate *standalone*
test cases which replicate the problem.

This is because the problem you describe makes no sense just with the
code snippets you posted, since the code is the same in both cases, as
you know.

Hence the problem lies somewhere outside, and so it's up to you to
provide two *complete* runnable programs which demonstrate the problem.

Since these programs read external data, you'll need to provide some
sample data files too (or better, include some short data items within
the code itself, if you can still replicate the problem like this)

--
Posted via http://www.ruby-forum.com/.



From: Brian Candler on
THAKUR PRASHANT SINGH wrote:
> Thanks for help I think I got the issue solved.
> file = File.open("kml/#{@file_names[file_index]}","w")
> file.write(@kml_file_data.to_xml)
> file.close
> The last line was missing. When I closed the file the problem
> disappeared

And this problematic code wasn't in the source you posted :-)

For a cleaner solution, you could use the same block form that you were
using for the zip files:

File.open("kml/#{@file_names[file_index]}","w") do |file|
file.write(@kml_file_data.to_xml)
end

This is better because the file will *always* be closed, even if an
exception is raised in the block.
--
Posted via http://www.ruby-forum.com/.

From: THAKUR PRASHANT SINGH on
I will do the changes proposed. It indeed looks a good solution
Thanks,
Prashant

-----Original Message-----
From: b.candler(a)pobox.com [mailto:b.candler(a)pobox.com]
Sent: Saturday, February 27, 2010 2:09 AM
To: ruby-talk ML
Subject: Re: Class Function call vs Normal Function call

THAKUR PRASHANT SINGH wrote:
> Thanks for help I think I got the issue solved.
> file = File.open("kml/#{@file_names[file_index]}","w")
> file.write(@kml_file_data.to_xml)
> file.close
> The last line was missing. When I closed the file the problem
> disappeared

And this problematic code wasn't in the source you posted :-)

For a cleaner solution, you could use the same block form that you were
using for the zip files:

File.open("kml/#{@file_names[file_index]}","w") do |file|
file.write(@kml_file_data.to_xml)
end

This is better because the file will *always* be closed, even if an
exception is raised in the block.
--
Posted via http://www.ruby-forum.com/.


First  |  Prev  | 
Pages: 1 2
Prev: class ExistingName
Next: Counting a string