From: Yusuke ENDOH Date: 2011-01-18T23:04:08+09:00 Subject: [ruby-core:34555] Re: [Ruby 1.9-Bug#4285] Ruby don't have asynchrounous exception safe syntax and It should have. Hi, 2011/1/18 Motohiro KOSAKI : > Endoh-san, Grr, my fault. I thought Thread.join call pthread_join, but it doesn't. I thought so :-) > But generically, Asynchrounous exception during OS resource handler class construction is still dangerous. new example is here. > > def foo > begin > f = open("example-file") > ensure > f.close > end > > timeout (1) { > foo > } > > if assignment of f was lost, we have no way to close f. Yes. Surely, the current Thread#raise is dangerous. > I still propose language enhancemnet for any async exception for 2.0. Basically agreed, but what is needed actually? I guess that we need these three features, including a semantics change. - a feature to block async exception t = Thread.new do # exception may be raised block_async_exc do # exception may NOT be raised end # exception may be raised end t.raise - a feature to allow async exception t = Thread.new do # exception may be raised block_async_exc do # exception may NOT be raised allow_async_exc do # exception may BE raised end # exception may NOT be raised end # exception may be raised end t.raise - async exception is blocked by default in rescue clauses and ensure clauses t = Thread.new do begin # exception may be raised ensure # exception may NOT be raised allow_async_exc do # exception may BE raised end end # exception may be raised end t.raise I remember that we discuss this topic with akr informally, but I forgot the conclusion... -- Yusuke Endoh