From: Tomoyuki Chikanaga Date: 2011-11-04T14:18:19+09:00 Subject: [ruby-core:40729] [ruby-trunk - Bug #5539] Readline.readline() blocks all threads Issue #5539 has been updated by Tomoyuki Chikanaga. Hi, In my environments, with GNU readline, your sample code work as expected. I've found that a variable rl_getc_function is pointed readline_getc() and readline_getc() call rb_funcall() to invoke IO#getbyte method. Obviously the IO#getbyte release GVL during blocking. I guess editline don't provide global variable rl_getc_function to customize getc function. I think your workaround is potentially conflicted with rl_getc_function because it end up to call ruby method without GVL. Thanks, ---------------------------------------- Bug #5539: Readline.readline() blocks all threads http://redmine.ruby-lang.org/issues/5539 Author: Christopher Huff Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0] The standard library Readline.readline() function blocks the thread it's called from without unlocking the VM, thus blocking all threads. This code demonstrates the problem: require 'pp' t = Thread.new {10.times {|x| puts x; sleep 1}} while(buf = Readline.readline) p buf if(buf == 'q') break end end Thread t will be blocked by the readline call, numbers being printed occasionally when lines are entered and readline() returns, rather than once per second. Reproduced on ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0] and ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]. The RubyInline gem allows a workaround: require 'inline' class BetterReadline inline :C do |builder| builder.include '' builder.include '' src = <