小编Chr*_*man的帖子

Twitter Streaming API - urllib3.exceptions.ProtocolError: ('连接中断:IncompleteRead

使用 tweepy 运行 python 脚本,该脚本在英语推文的随机样本中流式传输(使用 twitter 流 API)一分钟,然后交替搜索(使用 twitter 搜索 API)一分钟,然后返回。我发现的问题是,大约 40 秒后,流媒体崩溃并出现以下错误:

完整错误:

urllib3.exceptions.ProtocolError: ('连接中断:IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

读取的字节数可以在 0 到 1000 之间变化。

第一次看到流过早中断,搜索功能提前启动,搜索功能完成后,它再次返回流,第二次再次出现此错误时,代码崩溃。

我正在运行的代码是:

# Handles date time calculation
def calculateTweetDateTime(tweet):
    tweetDateTime = str(tweet.created_at)

    tweetDateTime = ciso8601.parse_datetime(tweetDateTime)
    time.mktime(tweetDateTime.timetuple())
    return tweetDateTime

# Checks to see whether that permitted time has past.
def hasTimeThresholdPast():
    global startTime
    if time.clock() - startTime > 60:
        return True
    else:
        return False

#override tweepy.StreamListener to add logic to on_status
class StreamListener(StreamListener):

    def on_status(self, …
Run Code Online (Sandbox Code Playgroud)

python twitter tweepy twitter-streaming-api

11
推荐指数
1
解决办法
4240
查看次数

标签 统计

python ×1

tweepy ×1

twitter ×1

twitter-streaming-api ×1