0.5.2: undefined method 'closed?'

65 views
Skip to first unread message

Mark Granoff

unread,
Sep 16, 2010, 1:46:09 PM9/16/10
to twitter4r-users
I started to see some errors with my twitter4r script that was using
v0.5.0, so I upgraded to 0.5.2. Now I am seeing this error
occasionally (but more than several times a day):

/usr/lib/ruby/1.8/net/http.rb:1060:in `request': undefined method
`closed?' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/consumer.rb:164:in
`request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
consumer_token.rb:25:in `request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
access_token.rb:11:in `request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
access_token.rb:24:in `get'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
base.rb:19:in `send'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
base.rb:19:in `rest_oauth_connect'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
timeline.rb:79:in `timeline_for'
from ./t4r2.rb:57

It doesn't happen ALL the time, but often enough.

Apologies if this is the wrong place to post such information.

-Mark

Susan Potter

unread,
Sep 16, 2010, 3:06:34 PM9/16/10
to twitter...@googlegroups.com
Hi Mark,

I *think* this might be a known bug in the version of Ruby you are using:
http://redmine.ruby-lang.org/issues/show/2708

Please verify whether you are using a version of Ruby that is affected
by this bug report and try to reproduce using only the HTTP Ruby
libraries (i.e. eliminating Twitter4R from the dependency mix).

Let me know if you see any differences in behavior on other versions of Ruby?

HTH,
Susan

> --
> You received this message because you are subscribed to the Google Groups "twitter4r-users" group.
> To post to this group, send email to twitter...@googlegroups.com.
> To unsubscribe from this group, send email to twitter4r-use...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/twitter4r-users?hl=en.
>
>

--
mailto:m...@susanpotter.net
twitter:@SusanPotter
github:mbbx6spp
blog:http://geek.susanpotter.net
linkedin:http://www.linkedin.com/in/susanpotter

Mark H. Granoff

unread,
Sep 16, 2010, 3:14:33 PM9/16/10
to twitter...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right you are, Susan!

I am seeing this behavior on my Ubuntu 10.04 system, which has Ruby 1.8.7. Interestingly, on my iMac, which a slightly different version of 1.8.7, I do not see the behavior.

I applied the suggested (one line) patch to http.rb on my Ubuntu system, and that seems to fix the issue. (Well, it makes the example code in that bug report behave as expected at any rate.)

Thanks!

- -Mark

- --
Mark H. Granoff
ma...@granoff.net
http://www.granoff.net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iQEcBAEBAgAGBQJMkmycAAoJEGTG72LTBYINv2cH/iXtKqvxBzTjJMtRU1smhD5l
dFnUtdee5PqTQP4B4J6PZGpnaxrqZqqm+h0Pqh5IRThijcmr9bPEh1EjnFpCDnrc
A0n/6b07BAelh+/qpH5kUMLnjCOWmlAsVLFY3Z3xoFPFCHHfDFL52XSPmhXw80dY
sBlZZP5NkL1TXIDHBCELXEHIYIndrLpZsYV5tF89e8iRJxdKz0Wzd9hySdIvFzb5
xjHv47n/oPUBrMSxbHejV3EFXT11FzpoKMXXwpwOmQB0autvYl4FXVERXpJVVEYd
3/pPm2X+uWiAw4P7uZuWElCPk2ErF3srGBASC19vc0OnSPIkpv2Wq69e3GPgIjM=
=bjTt
-----END PGP SIGNATURE-----

Mark Granoff

unread,
Sep 16, 2010, 3:36:51 PM9/16/10
to twitter4r-users
Well, the hits just keep on coming:

/usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill': execution expired
(Timeout::Error)
from /usr/lib/ruby/1.8/net/protocol.rb:134:in `rbuf_fill'
from /usr/lib/ruby/1.8/net/protocol.rb:86:in `read'
from /usr/lib/ruby/1.8/net/http.rb:2216:in `read_body_0'
from /usr/lib/ruby/1.8/net/http.rb:2177:in `read_body'
from /usr/lib/ruby/1.8/net/http.rb:2202:in `body'
from /usr/lib/ruby/1.8/net/http.rb:2141:in `reading_body'
from /usr/lib/ruby/1.8/net/http.rb:1052:in `request'
from /usr/lib/ruby/1.8/net/http.rb:1037:in `request'
from /usr/lib/ruby/1.8/net/http.rb:543:in `start'
from /usr/lib/ruby/1.8/net/http.rb:1035:in `request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/consumer.rb:164:in
`request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
consumer_token.rb:25:in `request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
access_token.rb:11:in `request'
from /var/lib/gems/1.8/gems/oauth-0.4.3/lib/oauth/tokens/
access_token.rb:24:in `get'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
base.rb:19:in `send'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
base.rb:19:in `rest_oauth_connect'
from /var/lib/gems/1.8/gems/twitter4r-0.5.2/lib/twitter/client/
timeline.rb:79:in `timeline_for'
from ./t4r2.rb:57

Probably another Ruby 1.8.7 issue, and not twitter4r. But still. :-(

On Sep 16, 3:14 pm, "Mark H. Granoff" <m...@granoff.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Right you are, Susan!
>
> I am seeing this behavior on my Ubuntu 10.04 system, which has Ruby 1.8.7. Interestingly, on my iMac, which a slightly different version of 1.8.7, I do not see the behavior.
>
> I applied the suggested (one line) patch to http.rb on my Ubuntu system, and that seems to fix the issue. (Well, it makes the example code in that bug report behave as expected at any rate.)
>
> Thanks!
>
> - -Mark
>
> On Sep 16, 2010, at 3:06 PM, Susan Potter wrote:
>
>
>
> > Hi Mark,
>
> > I *think* this might be a known bug in the version of Ruby you are using:
> >http://redmine.ruby-lang.org/issues/show/2708
>
> > Please verify whether you are using a version of Ruby that is affected
> > by this bug report and try to reproduce using only the HTTP Ruby
> > libraries (i.e. eliminating Twitter4R from the dependency mix).
>
> > Let me know if you see any differences in behavior on other versions of Ruby?
>
> > HTH,
> > Susan
>
> >> For more options, visit this group athttp://groups.google.com/group/twitter4r-users?hl=en.
>
> > --
> > mailto:m...@susanpotter.net
> > twitter:@SusanPotter
> > github:mbbx6spp
> > blog:http://geek.susanpotter.net
> > linkedin:http://www.linkedin.com/in/susanpotter
>
> > --
> > You received this message because you are subscribed to the Google Groups "twitter4r-users" group.
> > To post to this group, send email to twitter...@googlegroups.com.
> > To unsubscribe from this group, send email to twitter4r-use...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/twitter4r-users?hl=en.
>
> - --
> Mark H. Granoff
> m...@granoff.nethttp://www.granoff.net

Susan Potter

unread,
Sep 16, 2010, 4:15:03 PM9/16/10
to twitter...@googlegroups.com
It looks like a timeout interfering with a Thread#join issue. I think
I saw this before in 1.8.x (not sure which specific versions are
affected) myself. The work around before using the OAuth library
against Twitter API was to set the read_timeout to a higher number and
this reduced the occurrence of these execution expired scenarios
significantly.

Now when I moved Twitter4R's underlying client connection from the raw
Net::HTTP to the OAuth::Consumer I didn't see a convenient way to set
the read/receive timeout in that library, but I just noticed that
there is a way to access the Net::HTTP from the OAuth::Consumer, so
what I could do in v0.5.3 (ETA over this weekend) is allow you to use
the old Twitter::Configuration#timeout= method to set a higher timeout
and work around this problem.

If you need a solution now (due to production issues) it might look
something like the following (note:it is a total hack though):
http://gist.github.com/583075

(I haven't tested this, so there might be syntax issues, please let me
know if you have difficulties using the code above).

HTH,
Susan

> For more options, visit this group at http://groups.google.com/group/twitter4r-users?hl=en.

Reply all
Reply to author
Forward
0 new messages