From fea5a16216a6e7c64f5656c8cc1400f3f05eb331 Mon Sep 17 00:00:00 2001 From: Sokolov Yura aka funny_falcon Date: Mon, 21 Jan 2013 18:24:32 +0400 Subject: [PATCH 1/2] make compatible with sequel >= 3.41.0 --- lib/em-postgresql-sequel/fibered_connection_pool.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/em-postgresql-sequel/fibered_connection_pool.rb b/lib/em-postgresql-sequel/fibered_connection_pool.rb index 382d100..d913f11 100644 --- a/lib/em-postgresql-sequel/fibered_connection_pool.rb +++ b/lib/em-postgresql-sequel/fibered_connection_pool.rb @@ -2,11 +2,12 @@ module EM module Sequel class FiberedConnectionPool < ::Sequel::ConnectionPool - def initialize(opts={}, &block) + def initialize(*args) super @available = [] @waiting = [] + opts = args.last Integer(opts[:max_connections] || 4).times do @available << make_new(DEFAULT_SERVER) end From f76ec92aaa5e288eb9c02415f8ca95c2fdbf81f2 Mon Sep 17 00:00:00 2001 From: Sokolov Yura aka funny_falcon Date: Mon, 21 Jan 2013 18:27:44 +0400 Subject: [PATCH 2/2] do not block on consuming input, use EventMachine fully --- lib/em-postgresql-sequel/watcher.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/em-postgresql-sequel/watcher.rb b/lib/em-postgresql-sequel/watcher.rb index f28726d..24c3b1e 100644 --- a/lib/em-postgresql-sequel/watcher.rb +++ b/lib/em-postgresql-sequel/watcher.rb @@ -8,15 +8,17 @@ def initialize(client, deferrable) end def notify_readable - detach - begin - @client.block - @deferrable.succeed(@client.get_last_result) - rescue Exception => e - @deferrable.fail(e) + @client.consume_input + unless @client.is_busy + detach + begin + @deferrable.succeed(@client.get_last_result) + rescue Exception => e + @deferrable.fail(e) + end end end end end end -end \ No newline at end of file +end