Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > invalid arg to sysread deep within protocol.rb

Reply
Thread Tools

invalid arg to sysread deep within protocol.rb

 
 
William E. Rubin
Guest
Posts: n/a
 
      12-08-2005
I just made a script that fetches certain web pages, using Net::HTTP,
over and over in a loop. Everything worked fine, for about 5000
iterations, but then the following error was thrown (this is in Ruby
1.8.3):

C:/Ruby/lib/ruby/1.8/net/protocol.rb:133:in `sysread'
C:/Ruby/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
C:/Ruby/lib/ruby/1.8/timeout.rb:45:in `timeout'
C:/Ruby/lib/ruby/1.8/timeout.rb:62:in `timeout'
C:/Ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
C:/Ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
C:/Ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
C:/Ruby/lib/ruby/1.8/net/http.rb:1988:in `read_status_line'
C:/Ruby/lib/ruby/1.8/net/http.rb:1977:in `read_new'
C:/Ruby/lib/ruby/1.8/net/http.rb:1046:in `request'
C:/Ruby/lib/ruby/1.8/net/http.rb:944:in `request_get'

The appropriate part in protocol.rb is this:

def rbuf_fill
timeout(@read_timeout) {
@rbuf << @io.sysread(1024)
}
end

So sysread suddenly considers "1024" to be an invalid number of bytes
to read? After having considered it valid on each of the previous 5000
iterations?

Any clues? Thanks.

 
Reply With Quote
 
 
 
 
Logan Capaldo
Guest
Posts: n/a
 
      12-08-2005

On Dec 8, 2005, at 2:07 PM, William E. Rubin wrote:

> I just made a script that fetches certain web pages, using Net::HTTP,
> over and over in a loop. Everything worked fine, for about 5000
> iterations, but then the following error was thrown (this is in Ruby
> 1.8.3):
>
> C:/Ruby/lib/ruby/1.8/net/protocol.rb:133:in `sysread'
> C:/Ruby/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
> C:/Ruby/lib/ruby/1.8/timeout.rb:45:in `timeout'
> C:/Ruby/lib/ruby/1.8/timeout.rb:62:in `timeout'
> C:/Ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
> C:/Ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
> C:/Ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
> C:/Ruby/lib/ruby/1.8/net/http.rb:1988:in `read_status_line'
> C:/Ruby/lib/ruby/1.8/net/http.rb:1977:in `read_new'
> C:/Ruby/lib/ruby/1.8/net/http.rb:1046:in `request'
> C:/Ruby/lib/ruby/1.8/net/http.rb:944:in `request_get'
>
> The appropriate part in protocol.rb is this:
>
> def rbuf_fill
> timeout(@read_timeout) {
> @rbuf << @io.sysread(1024)
> }
> end
>
> So sysread suddenly considers "1024" to be an invalid number of bytes
> to read? After having considered it valid on each of the previous 5000
> iterations?
>
> Any clues? Thanks.


Maybe there aren't 1024 bytes left? According to the docs sysread is
supposed to raise EOFError at the end of the file, are you sure
that's not being raised?


 
Reply With Quote
 
 
 
 
William E. Rubin
Guest
Posts: n/a
 
      12-08-2005
> Maybe there aren't 1024 bytes left? According to the docs sysread is
> supposed to raise EOFError at the end of the file, are you sure
> that's not being raised?


Yes, I'm sure. Now that I look back at my original post, I notice that
I left out a crucial piece of information:

The error raised was an "Invalid Argument" error.

 
Reply With Quote
 
William E. Rubin
Guest
Posts: n/a
 
      12-08-2005
This seems to occur every few thousand iterations (not the same number
of iterations every time).

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass a multiline arg to exec('some.exe arg')? n00m Python 5 05-05-2008 02:58 PM
Timeout Error or sysread': end of file reached (EOFError) Muazzam Mushtaq Ruby 0 03-28-2006 05:05 AM
Trouble with setTimeout(arg, arg) nat.hourt@gmail.com Javascript 7 11-12-2005 05:13 PM
Deep Freeze In Deep Trouble johntangelo@gmail.com Computer Security 3 10-25-2005 11:49 PM
sysread and buffered I/O Hal Fulton Ruby 39 07-24-2004 03:45 AM



Advertisments