Created
June 10, 2011 14:59
-
-
Save bklang/1018994 to your computer and use it in GitHub Desktop.
Pry threading test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'pry' | |
#require 'rbtrace' | |
puts $$ | |
threads = [] | |
threads << Thread.new do | |
loop do | |
puts "Thread 1" | |
sleep 1 | |
end | |
end | |
threads << Thread.new do | |
pry | |
end | |
threads << Thread.new do | |
loop do | |
puts "Thread 2" | |
sleep 1 | |
end | |
end | |
threads.each {|t| t.join } |
Looks like you're probably linked against libedit. Did you follow the instructions in the blog post?
Interesting, I had not tried with Apple Ruby. Did you run the test code in the original Gist? What output did you receive?
When I get some time I will try with Ruby 1.9.3. In my tests both 1.8.7 and 1.9.2 (the broken versions) were compiled via RVM.
I compiled 1.9.3 off the branch by hand using gcc not llvm-gcc, I don't use RVM and I ran distclean since upgrading to OS X 10.7.
If I leave either ruby or ruby19 running it'll continue forever
$ GEM_HOME=~/tmp/gems gem list pry
*** LOCAL GEMS ***
pry (0.9.3)
$ curl -s https://raw.github.com/gist/1018994/0bf2737a6ac05e3be254cbe9924bcd65e9a01b57/pry-threads.rb | GEM_HOME=~/tmp/gems ruby
1563
Thread 1
Thread 2
Thread 1
Thread 2
Thread 2
Thread 1
^C-:25:in `join': Interrupt
from -:25
from -:25:in `each'
from -:25
$ curl -s https://raw.github.com/gist/1018994/0bf2737a6ac05e3be254cbe9924bcd65e9a01b57/pry-threads.rb | GEM_HOME=~/tmp/gems ruby19
1570
Thread 1
Thread 2
Thread 1Thread 2
Thread 2Thread 1
Thread 1
Thread 2
^C-:25:in `join': Interrupt
from -:25:in `block in <main>'
from -:25:in `each'
from -:25:in `<main>'
Another way to fix this with rvm:
rvm pkg install readline
rvm install 1.9.2 --with-readline-dir=$rvm_path/usr
Also works for other versions of Ruby.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I don't see this behavior with Apple Ruby 1.8.7 nor Ruby 1.9.3 (past preview 1):