Module: Couchbase::ForkHooks
- Defined in:
- lib/couchbase/fork_hooks.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/fork_hooks.rb
Instance Method Summary collapse
Instance Method Details
#_fork ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/couchbase/fork_hooks.rb', line 19 def _fork # :prepare stops the instances and only :parent or :child restarts them, so an asynchronous # exception is deferred everywhere except inside the fork itself. Thread.handle_interrupt(Object => :never) do parent_pid = Process.pid Couchbase::Backend.notify_fork(:prepare) begin Thread.handle_interrupt(Object => :immediate) do # A check point: an interrupt deferred during :prepare lands here, before the fork. Thread.pass super end ensure # Decided by pid rather than by the return value, which an exception raised after the fork # never delivers. Couchbase::Backend.notify_fork(Process.pid == parent_pid ? :parent : :child) end end end |