mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
48a735aff7
We can't actually lean on Rack::Lock's implementation, so we'll just copy it instead. It's simple enough that that's not too troubling.
21 lines
478 B
Ruby
21 lines
478 B
Ruby
require 'active_support/dependencies'
|
|
require 'rack/body_proxy'
|
|
|
|
module ActionDispatch
|
|
class LoadInterlock
|
|
def initialize(app)
|
|
@app = app
|
|
end
|
|
|
|
def call(env)
|
|
interlock = ActiveSupport::Dependencies.interlock
|
|
interlock.start_running
|
|
response = @app.call(env)
|
|
body = Rack::BodyProxy.new(response[2]) { interlock.done_running }
|
|
response[2] = body
|
|
response
|
|
ensure
|
|
interlock.done_running unless body
|
|
end
|
|
end
|
|
end
|