Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TweepError: Expecting length, unexpected value found #892

Closed
floricar opened this issue Jun 2, 2017 · 2 comments
Closed

TweepError: Expecting length, unexpected value found #892

floricar opened this issue Jun 2, 2017 · 2 comments
Labels
Bug This is regarding a bug with the library No Reproduction This is not reproducible Stale This is inactive, outdated, too old, or no longer applicable
Milestone

Comments

@floricar
Copy link

floricar commented Jun 2, 2017

Hello everyone, I am streaming tweets with Tweepy version 3.6 in a 2.7 Python version on w10.

What it seems weird to me is that after a minimum number of tweets fetched, tweepy raises this error:

Traceback (most recent call last):
File "escuchar_tweets.py", line 67, in
twitterStream.filter(track=keywords)
File "C:\Anaconda2\lib\site-packages\tweepy\streaming.py", line 450, in filter
self._start(async)
File "C:\Anaconda2\lib\site-packages\tweepy\streaming.py", line 364, in _start
self._run()
File "C:\Anaconda2\lib\site-packages\tweepy\streaming.py", line 297, in _run
six.reraise(*exc_info)
File "C:\Anaconda2\lib\site-packages\tweepy\streaming.py", line 266, in _run
self._read_loop(resp)
File "C:\Anaconda2\lib\site-packages\tweepy\streaming.py", line 323, in _read_loop
raise TweepError('Expecting length, unexpected value found')
tweepy.error.TweepError: Expecting length, unexpected value found

My code is the following:

class listener(StreamListener):

def on_data(self, data):
    try:
        print data
        saveFile = open('twbruto_'+args.hashtag_analizar+'_'+args.db_cliente+'.csv','a')
        saveFile.write(data)
        saveFile.write('\n')
        saveFile.close()
        prepro = preprocesatw.Preprocesadortw()
        prepro.preprocesar(twbruto=data, db=args.db_cliente, hashtag=args.hashtag_analizar)

        return True

    except BaseException as e:
        print 'failed in data', str(e)
        time.sleep(5)
    
def on_error(self, status):
    print status

I found on Stackoverflow these two questions, but unluckily no one seems to know the answer.
Here the question1 and question 2

Any help is really welcome,
thanks for reading!

@Harmon758
Copy link
Member

Despite several reports of this issue (#876, #883, #912, and the linked Stack Overflow questions), I've been unable to reproduce it.
For this issue to be actionable, more information is required about what data the stream is receiving that is unexpected. To begin with, a MCVE/SSCCE would help to debug the issue, but if the first linked Stack Overflow is an instance of one, more information might be required, as I'm unable to reproduce the issue with that example. The best way to debug this would be to modify the Tweepy source code to include the contents of stripped_line where that error is raised.

For code block usage, see https://help.github.com/articles/creating-and-highlighting-code-blocks/.

@Harmon758 Harmon758 added Bug This is regarding a bug with the library Need Follow-Up This needs to be followed up on to be actionable No Reproduction This is not reproducible Stale This is inactive, outdated, too old, or no longer applicable labels May 1, 2019
@Harmon758
Copy link
Member

This should now no longer be possible with 725ffb3.

@Harmon758 Harmon758 removed the Need Follow-Up This needs to be followed up on to be actionable label Jan 22, 2021
@Harmon758 Harmon758 added this to the 4.0 milestone Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is regarding a bug with the library No Reproduction This is not reproducible Stale This is inactive, outdated, too old, or no longer applicable
Projects
None yet
Development

No branches or pull requests

2 participants