[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Why doesn't Timeout work with String#=~

Eric Hodel

11/30/2006 5:39:00 AM

On Nov 29, 2006, at 0924 , Rob Biedenharn wrote:

> # I ran into trouble running a test on the result of a spell-
> checking action
> # with a combination of a poorly formed regular expression and
> having a third
> # misspelled word in the test phrase. It was taking a LONG time (not
> # completed overnight!) so I thought I'd put a timeout around the
> call so even
> # a truly gastly expression would be halted after some reasonalbe
> amount of
> # time.
> #
> # However, it appears that the regular expression match with =~
> doesn't get
> # interrupted by the timeout. Is this expected? I found a thread
> about
> # timeout and syscalls
> # (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/...
> 178726) that
> # says that syscalls are interrupted which seems to imply that
> things like
> # String#=~ ought to timeout also.
> #
> # Here's a "minimal" test that pulls the actual response out (so I
> don't have
> # to try and recreate a string that will cause the regexp to churn
> for a
> # long while).

Timeout uses threads and threads can only be switched when evaluating
ruby.

String#=~ is written in C and can't be interrupted by ruby's thread
scheduler.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!