class SQLite3::Database
def busy_handler_timeout=(milliseconds)
This is an alternative to #busy_timeout, which holds the GVL
but only retries up to the indicated number of +milliseconds+.
Sets a #busy_handler that releases the GVL between retries,
def busy_handler_timeout=(milliseconds) timeout_seconds = milliseconds.fdiv(1000) busy_handler do |count| now = Process.clock_gettime(Process::CLOCK_MONOTONIC) if count.zero? @timeout_deadline = now + timeout_seconds elsif now > @timeout_deadline next false else sleep(0.001) end end end