Created
September 2, 2011 17:10
-
-
Save Phrogz/1189184 to your computer and use it in GitHub Desktop.
Testing Pry with DRb and Threads
This file contains hidden or 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
SERVER = 'druby://localhost:9123' | |
require 'drb' | |
server = DRbObject.new_with_uri(SERVER) | |
server.go(42) | |
sleep(0.2) | |
server.go(17) | |
server.join_all |
This file contains hidden or 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
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