Method: Rack::Session::Couchbase#with_lock

Defined in:
lib/rack/session/couchbase.rb

#with_lock(env, default = nil) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/rack/session/couchbase.rb', line 94

def with_lock(env, default = nil)
  @mutex.lock if env['rack.multithread']
  yield
rescue ::Couchbase::Error::Connect, ::Couchbase::Error::Timeout
  if $VERBOSE
    warn "#{self} is unable to find Couchbase server."
    warn $!.inspect
  end
  default
ensure
  @mutex.unlock if @mutex.locked?
end