inueni/birdy

Streaming API behind

Opened this issue · 15 comments

It seems that the stream() is 1 post 'behind', is this supposed to be the case?

example:
response = client.stream.statuses.filter.post(track='@someperson')
for data in response.stream():
print data

if you now create a tweet on twitter:
@someperson testing 1

nothing will print
if you now create a second tweet on twitter:
@someperson testing 2

the data for the first tweet will now print out (@someperson testing 1)

if you create a third tweet:
@someperson testing 3

the data for the second tweet will now print out (@someperson testing2)

Shouldn't be the case, I'll have a look.

Hey,
I have the same issue too :(

It is getting cached somewhere most likely..
The streaming API sends data in chunks, does the code wait to receive a newline character/ EOF from the feed?

curious - has this been resolved and does the streaming API now work as expected? Thanks!

mmath commented

@travis5555 - just installed via PIP today and experienced the same issue. Be really great to get it fixed. I'd be happy to help - but I'm not sure where to begin.

I'll have a look when I get back from my vacation in a about a week. If anyone cares to look at the issue, the relevant code is in StreamResponse and StreamClient classes, although the "heavy lifting" is done by the requests library so it might also be an issue there.

hi, is there any update on the issue?

when i am trying to execute, i am gettings errors like
resource = client.stream.statuses.filter.post(track='twitter')
for data in resource.stream():
print data

Traceback (most recent call last):
File "webapp/streams.py", line 26, in
resource = client.stream.statuses.filter.post(track='twitter')
File "/home/ravi/PycharmProjects/twitter-livestream/venv/local/lib/python2.7/site-packages/birdy/twitter.py", line 86, in post
return self._client.request('POST', self._path, **params)
File "/home/ravi/PycharmProjects/twitter-livestream/venv/local/lib/python2.7/site-packages/birdy/twitter.py", line 167, in request
return self.handle_response(method, response)
File "/home/ravi/PycharmProjects/twitter-livestream/venv/local/lib/python2.7/site-packages/birdy/twitter.py", line 189, in handle_response
raise TwitterApiError('Unable to decode JSON response.', response=response, request_method=method)
birdy.twitter.TwitterApiError: Unable to decode JSON response. (POST https://stream.twitter.com/1.1/statuses/filter.json)

@raviarrow88 are you using StreamClient? What is the actual response from Twitter?

i used Appclient ... and later changed to StreamClient .... its working ...
resource = client.stream.statuses.filter.post(track='startup')
for data in resource.stream():
print data['text']

results:
#fintech #insur…
RT @GronDigital: Our pre-ICO is live
✅ +40% Bonus pre-ICO offer
Get your tokens here https://t.co/uptuifSmS7 #tokensale #preico #gro #gro…
RT @EmbajadaEspRiga: A new e-reader developed by Spanish startup @BraiBook converts text documents into the Braille alphabet thus helping p…
Playing with @Klipfolio. It's a cool dashboard tool for #startups. Check it out here: https://t.co/9MqOjbhWfT
RT @IAEStartupLab: Deuxième témoignage de Thierry Cottenceau avec son entreprise @virdys_sas
#creathlon2018 #entrepreneur #Innovation #star…

@raviarrow88 great, nice to hear it's working now.

Since there are no more reports of Streaming API lagging behind, I'll close this issue for now. If you encounter this problem, please open a new Issue.

ok i do hava a doubt ... is this is the correct process for the OAuth 2.0 ... ? bcoz OAuth 2 uses Appclient ... if i am using Appclient... i am getting as unauthorised login ...

@raviarrow88 to be honest, I don't know, I haven't worked with twitter API for a few years now, I just try to maintain this library as much as I can, but like I said haven't really used it in years and things have changes since then.

ok ok no problem @sect2k