Skip to content

Instantly share code, notes, and snippets.

@route
Last active December 10, 2015 03:08
Show Gist options
  • Save route/4372148 to your computer and use it in GitHub Desktop.
Save route/4372148 to your computer and use it in GitHub Desktop.
async_exec can return nil
require 'pg'
c = PG::Connection.open(dbname: 'database')
[
Thread.new { Thread.current[:r] = c.async_exec("SELECT * FROM users") },
Thread.new { Thread.current[:r] = c.async_exec("SELECT * FROM users") }
].each { |t| t.join; p t[:r] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment