Created
October 26, 2010 18:15
-
-
Save jimmys/647464 to your computer and use it in GitHub Desktop.
Example of em-mysqlplus
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 'fiber' | |
require 'em-synchrony' | |
require 'em-mysqlplus' | |
require 'benchmark' | |
EventMachine.synchrony do | |
db = EventMachine::Synchrony::ConnectionPool.new(size: 5) do | |
EventMachine::MySQL.new(host: 'localhost') | |
end | |
multi = EventMachine::Synchrony::Multi.new | |
multi.add :a, db.aquery("select sleep(1)") | |
multi.add :b, db.aquery("select sleep(1)") | |
res = multi.perform | |
p res | |
EventMachine.stop | |
end |
When I run this, I get this error:
/home/jimmys/lib/ruby/gems/1.9.1/gems/em-synchrony-0.1.5/lib/em-synchrony/connection_pool.rb:73:in `block in method_missing': undefined method `callback' for nil:NilClass (NoMethodError)
from /home/jimmys/lib/ruby/gems/1.9.1/gems/em-synchrony-0.1.5/lib/em-synchrony/connection_pool.rb:23:in `execute'
from /home/jimmys/lib/ruby/gems/1.9.1/gems/em-synchrony-0.1.5/lib/em-synchrony/connection_pool.rb:68:in `method_missing'
from db2.rb:14:in `block in <main>'
from /home/jimmys/lib/ruby/gems/1.9.1/gems/em-synchrony-0.1.5/lib/em-synchrony.rb:22:in `call'
from /home/jimmys/lib/ruby/gems/1.9.1/gems/em-synchrony-0.1.5/lib/em-synchrony.rb:22:in `block (2 levels) in synchrony'
I'm getting this too, just ran into it. Did you ever find a solution for this?
Yes my example was missing this:
require "em-synchrony/em-mysqlplus"
Yep, that did it. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sample code from http://www.slideshare.net/igrigorik/beyond-gem-install-mysql-in-ruby