/usr/lib/ruby/vendor_ruby/em-synchrony/mysql2.rb is in ruby-em-synchrony 1.0.5-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | begin
require 'mysql2/em'
rescue LoadError => error
raise 'Missing EM-Synchrony dependency: gem install mysql2'
end
module Mysql2
module EM
class Client
module Watcher
def notify_readable
detach
begin
result = @client.async_result
rescue Exception => e
@deferable.fail(e)
else
@deferable.succeed(result)
end
end
end
alias :aquery :query
def query(sql, opts={})
deferable = aquery(sql, opts)
# if EM is not running, we just get the sql result directly
# if we get a deferable, then let's do the deferable thing.
return deferable unless deferable.kind_of? ::EM::DefaultDeferrable
f = Fiber.current
deferable.callback { |res| f.resume(res) }
deferable.errback { |err| f.resume(err) }
Fiber.yield.tap do |result|
raise result if result.is_a?(::Exception)
end
end
end
end
end
|