On Fri, 2008-09-05 at 19:50 -0500, Charles Oliver Nutter wrote:
> Uwe Kubosch wrote:
> > Hi all!
> > 
> > In http://jira.codehaus.org/browse/JRUBY-2148 Headius says not to use
> > Timeout, but what should I use instead?  I want to read from /dev/ttyS0
> > but time out after a given time limit.  I use Timeout now, and it seems
> > to work, but maybe I should do it another way?
> > 
> > Any tips are welcome.
> 
> The bottom line with Timeout is that it may or may not work for you, and 
> under heavy load it may or may not cause problems in the rest of the 
> system. Timeout only works now by politely asking a target thread to 
> raise an exception when it gets around to it. If that thread is running 
> Ruby code, it generally works rather well. If it's calling Java code, 
> the raise will wait until it enters back into Ruby-space. And if it's 
> blocking on IO, it will continue to block on IO in most cases (though 
> this particular case is a bug...we should be able to safely wake up a 
> thread blocking on IO).

That would be great!  It is exactly my case (I think).  I am waiting for
input from a serial port.

> If it's working for you, I'd say continue to use it. Enough code depends 
> on timeout that we can't really eliminate it. But if you're concerned 
> enough to ask the question, it may be worth a little load-testing under 
> above-average circumstances for your app to help make sure it will 
> operate as expected.

No, it is not working in JRuby, only on MRI. And I am running out of
options.  Next thing to try is using javax.comm API and RXTX, but I had
REALLY hoped to avoid using native code...

Currently File#getc fails with "Illegal Seek" when reading
from /dev/ttyS0 on Linux.  If that worked, I could keep the reader
thread separate, and only have a timeout on threads copying data from my
own input buffer.


Uwe

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

    http://xircles.codehaus.org/manage_email


Reply via email to