Afficher un message
Vieux 14/03/2008, 15h32   #4
Paul Brannan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Thread#raise, Thread#kill, and timeout.rb are unsafe

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


  Réponse avec citation
 
Page generated in 0,05457 seconds with 9 queries