Readline::readline() blocking all other threads

J

Jean-Michel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top