fall back to blocking behavior for em_mysql2 AR adapter if EM isn't running
This commit is contained in:
parent
3ec92096ca
commit
678ff1cee9
|
@ -42,6 +42,7 @@ module Mysql2
|
||||||
end
|
end
|
||||||
|
|
||||||
def query(sql, opts={})
|
def query(sql, opts={})
|
||||||
|
if EM.reactor_running?
|
||||||
super(sql, opts.merge(:async => true))
|
super(sql, opts.merge(:async => true))
|
||||||
deferable = ::EM::DefaultDeferrable.new
|
deferable = ::EM::DefaultDeferrable.new
|
||||||
::EM.watch(self.socket, Watcher, self, deferable).notify_readable = true
|
::EM.watch(self.socket, Watcher, self, deferable).notify_readable = true
|
||||||
|
@ -53,6 +54,9 @@ module Mysql2
|
||||||
fiber.resume(err)
|
fiber.resume(err)
|
||||||
end
|
end
|
||||||
Fiber.yield
|
Fiber.yield
|
||||||
|
else
|
||||||
|
super(sql, opts)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue