Skip to content

Commit e675fee

Browse files
committed
Add comment
1 parent b7e32f0 commit e675fee

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/que/active_record/connection.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
module Que
44
module ActiveRecord
55
class << self
6-
# Use Rails' executor (if present) to make sure that the connection
7-
# we're using isn't taken from us while the block runs. See
8-
# https://github.com/que-rb/que/issues/166#issuecomment-274218910
96
def wrap_in_rails_executor(&block)
107
if defined?(::Rails.application.executor)
118
::Rails.application.executor.wrap(&block)
@@ -21,6 +18,9 @@ class << self
2118

2219
# Check out a PG::Connection object from ActiveRecord's pool.
2320
def checkout
21+
# Use Rails' executor (if present) to make sure that the connection
22+
# we're using isn't taken from us while the block runs. See
23+
# https://github.com/que-rb/que/issues/166#issuecomment-274218910
2424
Que::ActiveRecord.wrap_in_rails_executor do
2525
::ActiveRecord::Base.connection_pool.with_connection do |conn|
2626
yield conn.raw_connection
@@ -32,6 +32,9 @@ def checkout
3232
module JobMiddleware
3333
class << self
3434
def call(job)
35+
# Use Rails' executor (if present) to make sure that the connection
36+
# used by the job isn't returned to the pool prematurely. See
37+
# https://github.com/que-rb/que/issues/411
3538
Que::ActiveRecord.wrap_in_rails_executor do
3639
yield
3740
end

0 commit comments

Comments
 (0)