Shared State

Jeff McGee's Blog of Messages Worth Passing

Problems with prefetch in python requests

Posted on Thu 11 April 2013 in Tips

Requests is a great library for making HTTP requests. We're using it quite a bit in Infolab to talk to Twitter. Right before they released version 1.0, Requests made a slight change to its streaming API, so the old code results in this error message:

Traceback (most recent call last):
  File "", line 56, in <module>
  File "", line 47, in main
  File "", line 22, in store_tweets
  File "/usr/local/lib/python2.7/dist-packages/requests/", line 88, in post
    return request('post', url, data=data, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/requests/", line 44, in request
    return session.request(method=method, url=url, **kwargs)
TypeError: request() got an unexpected keyword argument 'prefetch'

You need to change the call that starts the streaming from something like this:

r ='', prefetch=False)

to this:

r ='', stream=True)
my photo

Jeff McGee — builder, problem solver, teacher, and general nerd.

jeffamcgee AT gmail