From: "Iñaki Baz Castillo" Date: 2011-01-13T03:43:29+09:00 Subject: Re: Exception Handling in Blocks 2011/1/12 Iñaki Baz Castillo : > Note that, even if you see the code as "sequential" it is not as > EventMachine works on iterations. So when you call memcache.get(:foo) > most probably a deferable object is created so the callback function > is called in a *later* iteration of EventMachine, so the begin-rescue > code has already been bypassed. Let me explain better: Your raised exception: Exception, "Tag :foo not found" is executed in a later iteration of the EM reactor so it cannot be captured by "rescue Exception => ex". This is, memcache.get(:foo) returned ok so the rescue doesn't take place. In a later EM iteration your exception is raised but then there is no rescue to capture it. Basically IMHO you shouldn't raise an exception within the block passed to memcache.get, and instead react on the same block (call there "puts 'Failed to get tag...'" and so on). -- Iñaki Baz Castillo