Timeout::timeout is broken
--------------------------

                 Key: JRUBY-2149
                 URL: http://jira.codehaus.org/browse/JRUBY-2149
             Project: JRuby
          Issue Type: Bug
    Affects Versions: JRuby 1.1RC2
            Reporter: Igor Minar
            Assignee: Thomas E Enebo


Timeout::timeout doesn't work as expected and the behavior differs between 
JRuby 1.0.3 and JRuby 1.1RC2.

Test case:
{code}
require 'timeout'
require 'benchmark'

n = 10000000
Benchmark.measure { 
  begin
    Timeout::timeout(1) { for i in 0..n do; (i + i % (i+1)) % (i + 10) ; end }
  rescue Timeout::Error => e
    puts e
  end 
}.to_s
{code}

JRuby 1.0.3 Result:
{code}
execution expired
=> " 27.474000   0.000000  27.474000 ( 27.473000)\n"
{code}
Timeout::Error exception was thrown, but only after the execution of the loop 
finished (which took more than 1 second)

JRuby 1.1RC2 Result:
{code}
=> " 27.895000   0.000000  27.895000 ( 27.895000)\n"
{code}
Note that the Timeout::Error exception was not thrown and the execution didn't 
time out after 1 second as expected.

MRI 1.8.6 Result:
{code}
execution expired
=> "  0.980000   0.010000   0.990000 (  1.006831)\n"
{code}
This is the only correct result (if {{n}} is high enough to cause the execution 
of the loop to last longer than one second.

I originally created [JRUBY-2148|http://jira.codehaus.org/browse/JRUBY-2148], 
because I suspected that the Java Integration is responsible for this, but that 
might not be the case.

Thanks,
Igor


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to