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:
parent
63f67869de
commit
226d9ef8a8
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue