litl / rauth

A Python library for OAuth 1.0/a, 2.0, and Ofly.
http://readthedocs.org/docs/rauth/en/latest/
MIT License
1.6k stars 174 forks source link

Multiple requests failing #180

Closed josuebrunel closed 9 years ago

josuebrunel commented 9 years ago

Hi guys, I'm writting a library (myql) which use rauth , but everytime i run more than one request, i get this error even though i used _header_auth=True_

[2015-05-08 13:45:49,823 DEBUG] [root.yoauth.token_is_valid] ELAPSED TIME : 2245.65489984

[2015-05-08 13:45:49,824 DEBUG] [root.yoauth.token_is_valid] TOKEN IS STILL VALID

[2015-05-08 13:45:49,827 DEBUG] [root.yoauth.token_is_valid] ELAPSED TIME : 2245.65891886

[2015-05-08 13:45:49,828 DEBUG] [root.yoauth.token_is_valid] TOKEN IS STILL VALID

[2015-05-08 13:45:49,833 INFO] [requests.packages.urllib3.connectionpool.connectionpool._new_conn] Starting new HTTP connection (1): query.yahooapis.com

[2015-05-08 13:45:50,196 DEBUG] [requests.packages.urllib3.connectionpool.connectionpool._make_request] "GET /v1/yql?format=json&q=select+%2A+from+fantasysports.teams.roster++where+team_key%3D%27mlb.l.1328.t.1%27+and+date%3D%272015-05-05%27&callback=&jsonCompact=False&diagnostics=False&debug=False HTTP/1.1" 200 None

1 Y! - Funston 0 11
[2015-05-08 13:45:50,287 DEBUG] [root.yoauth.token_is_valid] ELAPSED TIME : 2246.11847591

[2015-05-08 13:45:50,287 DEBUG] [root.yoauth.token_is_valid] TOKEN IS STILL VALID

Traceback (most recent call last):
  File "test.py", line 25, in <module>
    response = yql.select('fantasysports.teams.roster').where(['team_key','=',team],['date','=',year])
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/myql/myql.py", line 216, in where
    response = self.executeQuery(payload)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/myql/myql.py", line 89, in executeQuery
    response = self.oauth.session.get(self.url, params=payload, header_auth=True)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/requests/sessions.py", line 477, in get
    return self.request('GET', url, **kwargs)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/rauth/session.py", line 210, in request
    return super(OAuth1Session, self).request(method, url, **req_kwargs)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/home/yosuke/.virtualenvs/test/local/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ResponseNotReady())

This is my code

import sys
import myql
from myql.contrib.auth import YOAuth

if '__main__' == __name__:

    oauth = YOAuth(None, None, from_file='credentials.json')

    yql = myql.MYQL(format='json',oauth=oauth)

    teams = ('mlb.l.1328.t.1','mlb.l.1328.t.2')
    year = '2015-05-05'

    for team in teams :

        response = yql.select('fantasysports.teams.roster').where(['team_key','=',team],['date','=',year])
        if not response.status_code == 200:
            sys.exit(1)

        data = response.json()
        current_team = data['query']['results']['team']
        print current_team['team_id'],current_team['name'],current_team['number_of_trades'],current_team['number_of_moves']

I know this one has already been fixed, i can't figure out what's going wrong.

maxcountryman commented 9 years ago

What version of rauth and requests are you using?

josuebrunel commented 9 years ago

Hello @maxcountryman here they are

rauth==0.7.1                                                                                                                                   
requests==2.6.2 
josuebrunel commented 9 years ago

Thanks for the tip @maxcountryman. I just updated the version of _requests_

rauth==0.7.1                                                                                                                                   
requests==2.7.0                                  

And everything is working. I need to run more tests though before closing the issue if you don't mind. Thanks

josuebrunel commented 9 years ago

Thanks @maxcountryman the issue can be closed