Module: Que::Utils::Transactions
- Included in:
- Que
- Defined in:
- lib/que/utils/transactions.rb
Instance Method Summary collapse
Instance Method Details
#transaction ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/que/utils/transactions.rb', line 11 def transaction pool.checkout do if pool.in_transaction? yield else begin execute "BEGIN" yield rescue => error raise ensure # Handle a raised error or a killed thread. if error || Thread.current.status == 'aborting' execute "ROLLBACK" else execute "COMMIT" end end end end end |