I've been having a number of problems in Ruby of late with error handling in Threads. In particular, any time I encounter a problem in a thread, I was given no indication that something went wrong. It turns out that by default, an unhandled exception simply kills the current thread and you don't even hear about it unless you issue a "join" on the thread that raised the exception. I suppose proper coding practice would be to handle my exceptions appropriately, but for debugging, it is nice to know when something has gone wrong. The simple snippet of code:
Thread.abort_on_exception = true
takes care of this problem. With this modification, any unhandled exception kills all running threads and yields readable error information.
No comments:
Post a Comment