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.
Well, the problem is that there isn't really an alternative to timeout
since Ruby's APIs don't directly support timed-out IO. I'd be interested
in hearing Mentalguy's thoughts on this, since I know we've discussed
this in the past.
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).
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.
- Charlie
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email