I have a simple local script that needed threads, one to push things into a queue and one to pull them out and perform the actions (worker), and a Sinatra app.
Sometimes one of the threads, or the Sinatra would hang with a Ruby: SQLite3::BusyException: database is locked, because SQLite3 does not support concurrency.
ActiveRecord. A simple trick is to add a Timeout option on the
establish_connection block of
ActiveRecord, now SQLite3 won't trow the exception right away.
:adapter => 'sqlite3',
:database => 'database.sqlite3',
:host => 'localhost',
:timeout => 1000