Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'mysql2/em'
- i = 100_000
- connections = 0
- EM.run do
- (looop = proc{
- if connections < 4
- connections += 1
- client = Mysql2::EM::Client.new
- defer = client.query "SELECT 1 as first_query"
- defer.callback do |result|
- i -= 1
- connections -= 1
- client.close
- end
- end
- EM.next_tick(looop)
- }).call
- puts i if ( i % 100 ) == 0
- EM.stop if i == 0
- end
Add Comment
Please, Sign In to add comment