(3 secs) These parts deal with reentrancy. Basically, you need to store references to the threads that are currently inside the method.
Then, before the begin/rescue/ensure block, you check if the current thread is already inside the method, and if so, you use return yield to immediately pass execution to the block and return.
This return yield technique is used in multiple places inside of Sequel.
Any questions about return yield?