| Server IP : 74.208.236.108 / Your IP : 216.73.217.126 Web Server : Apache System : Linux info 3.0 #1337 SMP Tue Jan 01 00:00:00 CEST 2000 all GNU/Linux User : u90537543 ( 11015977) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /kunden/lib/ruby/vendor_ruby/mysql2/ |
Upload File : |
require 'eventmachine'
require 'mysql2'
module Mysql2
module EM
class Client < ::Mysql2::Client
module Watcher
def initialize(client, deferable)
@client = client
@deferable = deferable
@is_watching = true
end
def notify_readable
detach
begin
result = @client.async_result
rescue StandardError => e
@deferable.fail(e)
else
@deferable.succeed(result)
end
end
def watching?
@is_watching
end
def unbind
@is_watching = false
end
end
def close(*args)
@watch.detach if @watch && @watch.watching?
super(*args)
end
def query(sql, opts = {})
if ::EM.reactor_running?
super(sql, opts.merge(async: true))
deferable = ::EM::DefaultDeferrable.new
@watch = ::EM.watch(socket, Watcher, self, deferable)
@watch.notify_readable = true
deferable
else
super(sql, opts)
end
end
end
end
end