Ruby Thread#kill and ensure blocks
Here’s something interesting: If a thread is killed and the portion of code that was running has a corresponding ensure block, that block will be executed before the thread is killed. This is nice in that the utility of ensure is maintained (IO objects will be closed, etc.), but it’s perhaps unintuitive that the semantics of Thread.kill would allow for that. I suppose it’s like command line kill and not kill -9
2 Comments