Catch timeout errors on read/write inside stream

git-svn-id: file:///home/svn/incoming/trunk@2850 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
HD Moore 2005-09-16 03:28:51 +00:00
parent 63f67869de
commit 226d9ef8a8
1 changed files with 12 additions and 6 deletions

View File

@ -112,9 +112,12 @@ module Stream
#
def timed_write(buf, wait = def_write_timeout, opts = {})
if (wait and wait > 0)
timeout(wait) {
return write(buf, opts)
}
begin
timeout(wait) {
return write(buf, opts)
}
rescue Timeout::Error
end
else
return write(buf, opts)
end
@ -125,9 +128,12 @@ module Stream
#
def timed_read(length = nil, wait = def_read_timeout, opts = {})
if (wait and wait > 0)
timeout(wait) {
return read(length, opts)
}
begin
timeout(wait) {
return read(length, opts)
}
rescue Timeout::Error
end
else
return read(length, opts)
end