Hi, I am learning ruby and writing my first non-trivial program and I’m
running into a few issues.
First of all, I am having problems getting threading to work consistently. I
am simply having the thread execute a code block which loads a YAML file
into a ruby object. The thread completes when the file is an empty file
(just a dash), but when the file has YAML code, the thread just never seems
to lock at that part of the code. When I join it later it does complete
properly. Here is the simple code example:
loadingthread = Thread.new(‘maps/currentmap.yml’) { |filename|
puts "starting thread"
mapfile = File.open(filename)
puts "opened file"
amap = YAML::load(mapfile)
puts "generated object"
mapfile.close
puts “thread all done”
}
Any advice for a ruby-newbie would be appreciated 
Oh sorry, that should have read:
The thread completes when the file is an empty file (just a dash), but when
the file has YAML code, the thread just seems to lock at that part of the
code.
Also, I have a question regarding the performance of the ruby YAML module.
In my test, when I load a big file into a ruby object (200k+) it takes about
20 seconds or so but when I save that object it only takes about 5 seconds.
I can’t understand why it would take so much longer to read in the object as
opposed to saving off the object. I really need the load to only take about
5 seconds too. Anyone know anything more about the performance
issues/limitations of ruby YAML?
···
-----Original Message-----
From: info@irvinehosting.net [mailto:info@irvinehosting.net]
Sent: Wednesday, January 22, 2003 1:27 AM
To: ruby-talk ML
Subject: Question regarding threads and perhaps YAML
Hi, I am learning ruby and writing my first non-trivial program and I’m
running into a few issues.
First of all, I am having problems getting threading to work consistently.
I am simply having the thread execute a code block which loads a YAML file
into a ruby object. The thread completes when the file is an empty file
(just a dash), but when the file has YAML code, the thread just never seems
to lock at that part of the code. When I join it later it does complete
properly. Here is the simple code example:
loadingthread = Thread.new(‘maps/currentmap.yml’) { |filename|
puts "starting thread"
mapfile = File.open(filename)
puts "opened file"
amap = YAML::load(mapfile)
puts "generated object"
mapfile.close
puts “thread all done”
}
Any advice for a ruby-newbie would be appreciated 
Could you send me your YAML doc? The parser must be choking on it or
something. Here’s the thread code I’m using:
require ‘yaml’
loadingthread = Thread.new(‘CHANGELOG’) { |filename|
puts “starting thread”
mapfile = File.open(filename)
puts “opened file”
amap = YAML::load(mapfile)
puts “generated object”
mapfile.close
puts “thread all done”
}
loadingthread.join
_why
···
On Wednesday 22 January 2003 03:05 am, info@irvinehosting.net wrote:
Oh sorry, that should have read:
The thread completes when the file is an empty file (just a dash), but when
the file has YAML code, the thread just seems to lock at that part of the
code.