Skip to content

Instantly share code, notes, and snippets.

@bklang
Created June 10, 2011 14:59
Show Gist options
  • Save bklang/1018994 to your computer and use it in GitHub Desktop.
Save bklang/1018994 to your computer and use it in GitHub Desktop.
Pry threading test
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 }
@drbrain
Copy link

drbrain commented Aug 3, 2011

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>'

@bklang
Copy link
Author

bklang commented Feb 19, 2012

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