19 Feb '13, 8pm
Rails, concurrency, database drivers, and an example of why @tenderlove is awesome:
It depends on the database driver. The pg driver allows both synchronous and asynchronous calls. The synchronous calls will block all threads until the results return where the asynchronous ones require two method calls, but allow the interpreter to continue processing other things. The Rails pg adapter uses the async api . The mysql2 adapter uses rb_thread_blocking_region whenever IO would block (especially on queries ), so this will allow the Ruby interpreter to continue even if reading from the socket would block. SQLite3 adapter doesn't use rb_thread_blocking_region, but I haven't been able to get it to block the interpreter. If you can write tests that demo blocking the interpreter, I would greatly appreciate it (so I can fix it). I am unsure about the other adapters.