Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Tweepy多线程与喜欢的tweets_Python_Tweepy - Fatal编程技术网

Python Tweepy多线程与喜欢的tweets

Python Tweepy多线程与喜欢的tweets,python,tweepy,Python,Tweepy,我有一个功能,就像我拥有两个账户的少数用户一样,当一条新的推特流进来时,它就会被调用。我的喜欢功能有一个延迟,但是在两个喜欢推文的帐户之间,所以有时候如果新推文是背靠背的,就会错过。有没有人能为我提供一个解决方案,让我在每次收到新的推文时都调用这个函数,但仍然有延迟? 我的流课程: def on_status(self, status): if self.from_creator(status): self.login_to_all_accounts(status.

我有一个功能,就像我拥有两个账户的少数用户一样,当一条新的推特流进来时,它就会被调用。我的喜欢功能有一个延迟,但是在两个喜欢推文的帐户之间,所以有时候如果新推文是背靠背的,就会错过。有没有人能为我提供一个解决方案,让我在每次收到新的推文时都调用这个函数,但仍然有延迟? 我的流课程:

def on_status(self, status):
    if self.from_creator(status):
           self.login_to_all_accounts(status.id,tweet_text,status.user.screen_name)
我喜欢的功能:

def login_to_all_accounts(self, status_id, tweet_text, user_screen_name):
    with open('keys_and_tokens.json') as f:
        keys_and_tokens = json.load(f)
    for screen_name in keys_and_tokens:
        consumer_key = keys_and_tokens[screen_name]["consumer_key"]
        consumer_secret = keys_and_tokens[screen_name]["consumer_secret"]
        access_token = keys_and_tokens[screen_name]["access_token"]
        access_token_secret = keys_and_tokens[screen_name]["access_token_secret"]
        temp_api = oauth_login(consumer_key,consumer_secret,access_token,access_token_secret)
        time.sleep(random.randint(30,45))
        self.execute_operations(temp_api,status_id,tweet_text,user_screen_name)
        time.sleep(random.randint(61,90))