title: How to respond a Rails request within a configurable timeout
body: <p>I want to achieve the following behavior in my controllers' action without the usage of Timeout module:</p>
  
  <pre><code>class AdminController &lt; ApplicationController
    def example
      Timeout.timeout(params[:timeout].to_i) do
        ... # try to process the request within params[:timeout] seconds
      end
    rescue Timeout::Error
      render nothing: true, status: :gateway_timeout
    end
  end
  </code></pre>
  
  <p>I want to avoid the usage of Timeout because it's causing many bugs in my application, including database connection leaks. Some other problems reported at:
  <a href="http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/">http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/</a></p>