leftbee/em-postgresql-adapter — pull request #8 by rud (2011-12-13 11:07:18+00:00)
Title: Feature/fix example

This is basically an addon to the previous pull-request, getting the requires just right for the example.

When I have a user setup in my database, and then run this example, I get this output:

ruby examples/standalone.rb
D, [2011-12-13T12:02:20.771240 #88295] DEBUG -- : (1101.3ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.771571 #88295] DEBUG -- : (1101.5ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.771735 #88295] DEBUG -- : (1101.4ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.772156 #88295] DEBUG -- : (1101.6ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.772347 #88295] DEBUG -- : (1101.4ms) select pg_sleep(1.1)
first batch done
D, [2011-12-13T12:02:20.772890 #88295] DEBUG -- : (0.1ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.772961 #88295] DEBUG -- : PGError: another command is already in progress
: select pg_sleep(1.1)
#
D, [2011-12-13T12:02:20.773218 #88295] DEBUG -- : (0.0ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.773272 #88295] DEBUG -- : PGError: another command is already in progress
: select pg_sleep(1.1)
#
D, [2011-12-13T12:02:20.773458 #88295] DEBUG -- : (0.0ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.773510 #88295] DEBUG -- : PGError: another command is already in progress
: select pg_sleep(1.1)
#
D, [2011-12-13T12:02:20.773698 #88295] DEBUG -- : (0.0ms) select pg_sleep(1.1)
D, [2011-12-13T12:02:20.773750 #88295] DEBUG -- : PGError: another command is already in progress
: select pg_sleep(1.1)
#
D, [2011-12-13T12:02:21.876773 #88295] DEBUG -- : (1104.1ms) select pg_sleep(1.1)
2.2310032844543457

The root-cause for this is the AR connection-pool is per-thread, so the same connection is reused for each request. I'm working on adding specs to demonstrate how to play nice