Permalink
Browse files

Merge pull request #89 from jormon/fix-deferable

fix nil callback issues when EM is not running
  • Loading branch information...
2 parents 0ab0f07 + 13371de commit 1bdfce98a05c469e9f4cf1b62e21f39fd0c72d6b @igrigorik committed Dec 1, 2011
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/em-synchrony/mysql2.rb
@@ -24,6 +24,10 @@ def notify_readable
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) }

0 comments on commit 1bdfce9

Please sign in to comment.