From: anselm Date: 2007-03-22T02:55:12+09:00 Subject: Catching thread exceptions (Net::IMAP timeout) Hello :) I have a question : is it possible to catch exceptions that are raised on a thread by another thread ? Say if you have two threads, A and B and thread A does B.raise "bug" Is there a way for thread B to catch and process that exception, and resume it's execution where it was at ? Specifcally, I am asking this because of the Net::IMAP library. Because responses are asynchronous, the Net::IMAP library runs on two threads. The main thread, and another thread which is there to recieve data from the IMAP server. In most cases this works fine, because exceptions only get raised when you are calling the Net::IMAP library (so you can have your begin...rescue block and deal with it appropriately). However, as specified in the Imap4rev1 RFC, the IMAP server is allowed to send you data without having been prompted for anything -- and one case where it does this is when it sends a timeout message (ByeResponseError). When the Net::IMAP library gets this message, it raises an exception on the main thread -- and this can happen at any time. I can deal with the timeouts -- but I don't know how to catch that exception in a way that allows me to resume my thread of execution ! Thanks for any help, Anselm