Thread Timeout



  • 1. block-ish expression?
    I would like to conveniently create objects and define their methods right at the point where I want to pass them into a method call. These objects are a lot like blocks, except that I need more than one interface on them. === with a block m(a, b) { |x| ... } def m(a, b) yield end ==== what I want m(a, b, <inline_object_creation_expression_including: def foo, def bar>) def m(a, b, c) if ... ... end Is there some convenient way to do this? Thanks!
  • 2. redcloth / textile : preventing characters from being converted
    Hi, Apologies if this is the wrong place for this - it might really be a textile question, I'm not sure. Am I correct in thinking that, text that is indented and enclosed between HTML tags, should be unaltered by RedCloth? My problem is that I'm using RedCloth to convert a file of textile markup which also contains some CSS styles defined in the <HEAD>. I thought that, as long as the CSS text was indented, then RedCloth wouldn't touch it. However, it still converts straight quotation marks to the nicer-looking (but apparently not valid CSS) curly ones. I get the feeling I may just be going about this wrong, so any tips would be appreciated. Thanks, Kevin
  • 3. Detecting rubyw
    Is there any way (on Windows) to detect if a script is running under rubyw.exe, i.e. headless? Thanks, Nathaniel Terralien, Inc. <:((><

Thread Timeout

Postby Francesco Vollero » Tue, 22 Jun 2010 02:08:05 GMT

Hi list,

i'm working with multiple threads, with a producer-consumer like algorithm.
My problem is that i want that the "consumer" thread take all the 
content every *N* seconds and after go to "sleep" again, It's the 
Timeout library a good solution? I can use Ruby 1.9 and 1.8 as well.

Francesco Vollero

Re: Thread Timeout

Postby Robert Klemme » Tue, 22 Jun 2010 02:49:27 GMT

Why do you want to do that?  If you want to schedule activity with 
particular intervals then I believe a scheduling solution would be 
better.  In a simplistic solution you can have the main thread sleep for 
the interval and create a thread for each task.

Kind regards


remember.guy do |as, often| as.you_can - without end

Re: Thread Timeout

Postby Francesco Vollero » Tue, 22 Jun 2010 09:59:15 GMT

Il 20/06/10 19.50, Robert Klemme ha scritto:

Robert, a draft example ?

Re: Thread Timeout

Postby Robert Klemme » Wed, 23 Jun 2010 01:45:16 GMT

You go first. ;-)  You did not yet describe what kind of problem you are 
trying to solve.

Btw, sleeping and starting threads isn't that hard.



remember.guy do |as, often| as.you_can - without end

Similar Threads:

1.Non-Threaded Timeout?

Hell all,

I'm looking for a way to implement a non-threaded timeout.  I am running
some Monte Carlo simulations using an external application via an OLE
interface.  There are times where the external application seems to hang
up, so I'm looking for a way to detect this and continue on with my
simulation if the external application takes too long.

Any suggestions?

2.Thread#raise, Thread#kill, and timeout.rb are unsafe

3.Timeout::timeout and Socket timeout

Hi ..

I would like to suggest that Socket trap ETIMEDOUT and raise Timeout::Error 
when a socket timeout occurs.  This would allow the following:

     Timeout::timeout(to) do
         t =,port)
               # do socket stuff
   rescue Timeout::Error => e
      p "Timeout --> #{e}"
   rescue Exception => e
        p "Exception --> #{e}"

Rather than having a separate rescue clause.

Any thoughts?

-mark.  (probertm @ acm dot org)

4.Nested threading? implications to timeout()

5.Nested threading? implications to timeout()

6. Catching thread exceptions (Net::IMAP timeout)

7. Timeouts with Thread#join and Net:HTTP

8. timeouts with threads and SIGALRM

Return to ruby


Who is online

Users browsing this forum: No registered users and 21 guest