Readline::readline() blocking all other threads

Discussion in 'Ruby' started by Jean-Michel, Dec 22, 2007.

  1. Jean-Michel

    Jean-Michel Guest

    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
    Jean-Michel, Dec 22, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hendra Gunawan
    Replies:
    1
    Views:
    12,415
    Allan Herriman
    Apr 8, 2004
  2. Andre Kelmanson

    blocking i/o vs. non blocking i/o (performance)

    Andre Kelmanson, Oct 10, 2003, in forum: C Programming
    Replies:
    3
    Views:
    912
    Valentin Tihomirov
    Oct 12, 2003
  3. nukleus
    Replies:
    14
    Views:
    816
    Chris Uppal
    Jan 22, 2007
  4. Alexandru  Mosoi

    blocking all threads

    Alexandru Mosoi, Sep 29, 2008, in forum: Python
    Replies:
    1
    Views:
    293
    sturlamolden
    Sep 29, 2008
  5. Replies:
    0
    Views:
    290
Loading...

Share This Page