Method: Puma::DSL#on_thread_exit

Defined in:
lib/puma/dsl.rb

#on_thread_exitObject

Provide a block to be executed after a thread is trimmed from the thread pool. Be careful: while this block executes, Puma’s main loop is blocked, so no new requests will be picked up.

This hook only runs when a thread in the threadpool is trimmed by Puma. It does not run when a thread dies due to exceptions or any other cause.

Return values are ignored. Raising an exception will log a warning.

This hook is useful for cleaning up thread local resources when a thread is trimmed.

This can be called multiple times to add several hooks.

Examples:

before_thread_exit do
  puts 'On thread exit...'
end


965
966
967
968
969
# File 'lib/puma/dsl.rb', line 965

def before_thread_exit(&block)
  Puma.deprecate_method_change :on_thread_exit, __callee__, __method__

  process_hook :before_thread_exit, nil, block
end