【问题标题】:Twython Api: IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)Twython Api: IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)
【发布时间】:2015-08-07 12:58:15
【问题描述】:

我正在尝试使用 Twython Streaming API,但经过一段时间后我收到以下错误(消耗了大约 220 多条推文)

这是发生错误的堆栈跟踪。我已经看到了升级请求库的建议 - 但它已经更新了。

chunk = self.fp.read(min(amt, MAXAMOUNT))
if not chunk:
   raise IncompleteRead(''.join(s), amt)
s.append(chunk)
amt -= len(chunk)

IncompleteRead: IncompleteRead(0 bytes read, 1 more expected)

count 214

【问题讨论】:

    标签: python twitter twitter-streaming-api twython


    【解决方案1】:

    我遇到了同样的问题,并阅读了 GitHub 上关于它的线程,https://github.com/ryanmcgrath/twython/issues/288,建议的解决方案是用 try/catwhile True 包装跟踪器:#Endless loop:个性化以满足您自己的目的

    try: 
        stream.statuses.filter(track='foo bar,foobar,more search strings here')
    except:
        #e = sys.exc_info()[0]  #Get exception info (optional)
        #print 'ERROR:',e  #Print exception info (optional)
        continue
    

    我已经在使用 Twython 时实现了它,到目前为止,虽然错误已经发生了一两次(显然是 Twitter 故障或网络错误),但它会重新启动并正常继续。

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 2012-08-09
      • 2021-09-13
      • 2020-02-07
      • 2019-04-18
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 2013-01-04
      相关资源
      最近更新 更多