Sha256: 5f613661f9b9e8f2a7d97a46c400d557737211197535b374059cd136800ce406

Contents?: true

Size: 648 Bytes

Versions: 4

Compression:

Stored size: 648 Bytes

Contents

# frozen_string_literal: true
module Dynflow
  module Executors

    require 'dynflow/executors/parallel'

    # Every time we run a code that can be defined outside of Dynflow,
    # we should wrap it with this method, and we can ensure here to do
    # necessary cleanup, such as cleaning ActiveRecord connections
    def self.run_user_code
      clear_connections = defined?(::ActiveRecord) && ActiveRecord::Base.connected? && ActiveRecord::Base.connection.open_transactions.zero?
      yield
    ensure
      ::ActiveRecord::Base.clear_active_connections! if clear_connections
      ::Logging.mdc.clear if defined? ::Logging
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynflow-1.4.3 lib/dynflow/executors.rb
dynflow-1.4.2 lib/dynflow/executors.rb
dynflow-1.4.1 lib/dynflow/executors.rb
dynflow-1.4.0 lib/dynflow/executors.rb