[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Thread#raise, Thread#kill, and timeout.rb are unsafe

Yukihiro Matsumoto

3/13/2008 10:43:00 PM

Hi,

In message "Re: Thread#raise, Thread#kill, and timeout.rb are unsafe"
on Fri, 14 Mar 2008 06:00:54 +0900, Paul Brannan <pbrannan@atdesk.com> writes:

|I'm not convinced KeyboardInterrupt can be handled safely, either, in a
|script. What happens if a KeyboardInterrupt exception is raised inside
|an ensure block? It could easily result in resource leaks.

You are right, but keyboard interrupt has been there so long in the
history, and we hardly see such leak problems, so I assume it's safer
than you might think. At least, we cannot not removed the interrupts
from the language.

matz.

1 Answer

Paul Brannan

3/14/2008 1:33:00 PM

0

On Fri, Mar 14, 2008 at 07:43:28AM +0900, Yukihiro Matsumoto wrote:
> Hi,
>
> In message "Re: Thread#raise, Thread#kill, and timeout.rb are unsafe"
> on Fri, 14 Mar 2008 06:00:54 +0900, Paul Brannan <pbrannan@atdesk.com> writes:
>
> |I'm not convinced KeyboardInterrupt can be handled safely, either, in a
> |script. What happens if a KeyboardInterrupt exception is raised inside
> |an ensure block? It could easily result in resource leaks.
>
> You are right, but keyboard interrupt has been there so long in the
> history, and we hardly see such leak problems, so I assume it's safer
> than you might think. At least, we cannot not removed the interrupts
> from the language.

For simple scripts, KeyboardInterrupt is probably the right behavior.

For applications that use an event loop, we can use trap('INT') to
disable KeyboardInterrupt.

I wonder if there should be an equivalent trap mechanism for other
asynchronous exceptions?

Paul