We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I frequently get 'another command is already in progress' when performing asynchrous requests simultaneously. Am I doing something wrong?
I do something like this:
EM.run do df1 = pg.query_defer('select * from foo') df2 = pg.query_defer('select * from foo') df1.callback { |result| puts Array(result).inspect } df1.errback {|ex| raise ex } df2.callback { |result| puts Array(result).inspect } df2.errback {|ex| raise ex } end
/home/rubyuser/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/em/deferrable.rb:158:in `call' /home/rubyuser/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/em/deferrable.rb:158:in `set_deferred_status' /home/rubyuser/.rvm/gems/ruby-2.1.1/gems/eventmachine-1.0.3/lib/em/deferrable.rb:198:in `fail' /home/rubyuser/.rvm/gems/ruby-2.1.1/gems/em-pg-client-0.3.2/lib/pg/em.rb:491:in `async_autoreconnect!' /home/rubyuser/.rvm/gems/ruby-2.1.1/gems/em-pg-client-0.3.2/lib/pg/em.rb:568:in `block in exec_prepared_defer'
The text was updated successfully, but these errors were encountered:
You can't run concurrent parallel operations on the single PG::EM::Client connection instance. Neither you couldn't do it on a single PG::Connection.
What you need is a connection pool, which fortunately is included in this gem:
require 'pg/em/connection_pool' pg = PG::EM::ConnectionPool.new(size: 10, dbname: 'foo')
where size: is a maximum number of allowed connections per pool, and the other options are passed directly to connection instances.
Then your example should work.
See "Connection Pool" chapter in README.md for some more examples.
Sorry, something went wrong.
Ok, I see. Thank you very much!
No branches or pull requests
I frequently get 'another command is already in progress' when performing asynchrous requests simultaneously. Am I doing something wrong?
I do something like this:
The text was updated successfully, but these errors were encountered: