Skip to content

Instantly share code, notes, and snippets.

@Phrogz
Created September 2, 2011 17:10
Show Gist options
  • Save Phrogz/1189184 to your computer and use it in GitHub Desktop.
Save Phrogz/1189184 to your computer and use it in GitHub Desktop.
Testing Pry with DRb and Threads
SERVER = 'druby://localhost:9123'
require 'drb'
server = DRbObject.new_with_uri(SERVER)
server.go(42)
sleep(0.2)
server.go(17)
server.join_all
SERVER = 'druby://localhost:9123'
require 'drb'
require 'pry'
$pry = Mutex.new
class Server
def initialize
@instances = {}
end
def go(id)
@instances[id] ||= Thread.new{
5.times{ |i|
$pry.synchronize{ binding.pry }
sleep 1
}
}
end
def join_all
@instances.each{ |_,thread| thread.join }
end
end
DRb.start_service( SERVER, Server.new )
DRb.thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment