rails 2 and slow external services

Eric Wong normalperson at yhbt.net
Sun Dec 19 20:00:15 EST 2010

ghazel at gmail.com wrote:
> I believe I found a bug in ThreadTimeout. It seems to be terminating a
> request immediately every @timeout seconds. I'm using :ThreadSpawn and
> my initializer is:
> use Rainbows::ThreadTimeout, :timeout => 299
> The observed behavior is that the request dies < 1 second later with
> Rainbows::ThreadTimeout::ExecutionExpired. If I look 299 seconds back
> in the log, I see another request killed prematurely. If I look 299
> further back from that, I see the process started at this time.
> Glancing at the code:
>         now = Time.now
>         @lock.synchronize do
>           @active.delete_if do |thread, time|
>             time >= now and thread.raise(ExecutionExpired).nil?
>           end
>         end
> The "time >= now" seems incorrect to me. Since "time" is set to
> "Time.now + @timeout" it will be greater than Time.now while the
> request still has time left. I believe that should read "now >= time".

Yup, pushing out a trivial fix in a bit along with a test case.

(sorry for the delayed response, been under the weather lately)
Eric Wong

More information about the rainbows-talk mailing list