Readline::readline() blocking all other threads

Hi:

I have noticed an issue with readline since upgrading to Leopard.
The readline command seems to be blocking all the other active threads

require ‘readline’
other = Thread.new do
time = Time.now
while true
time = Time.now
sleep(2)
puts “slept(#{time - Time.now})”
end
end
cli = Thread.new do
loop do
Readline::readline("\nreadline > ", true)
end
end
cli.join

+++ expected behavior:

$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-freebsd6.2]
$ ruby testreadline.rb

readline >

readline > slept(-2.080508)
slept(-2.019907)
slept(-2.020017)
slept(-2.020015)
slept(-2.020017)
slept(-2.020017)
slept(-2.020037)
slept(-2.019993)
testreadline.rb:16:in `join’: Interrupt
from testreadline.rb:16

===============================

+++ Bogus behavior on OS X 10.5.1

$ ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [powerpc-darwin9.1.0]

Readline::readline("\nreadline > ", true)
Thread.pass   <<< so the 'other' thread gets a chance to run.

$ ruby readline.rb

readline >

readline >
slept(-6.416737)

readline >
slept(-6.303147)

readline >
slept(-3.599555)

readline >
slept(-7.511554)

readline >

Is this a known issue ?

Jean-Michel

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs