WeiboService.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ugc.aggregator 作者: Dreamcatcher-GIS 项目源码 文件源码
def get_weibo_users_timeline_async(self, id_str):
        def get_timeline_data(api_account):
            while not tasks.empty():
                client = WeiboAPIService(appKey=api_account[1], appSecret=api_account[2], token=api_account[3])
                id = tasks.get_nowait()
                data.put_nowait(client.get_weibo_user_timeline(id))
        result_data = []
        data = Queue()
        tasks = Queue()

        for id in id_str.split(",")[0:10]:
            tasks.put_nowait(id)
        # ?????api??
        if self.api_accounts == None:
            self.api_accounts = self.weiboDAO.get_weibo_accounts()
        threads = []
        for account in self.api_accounts:
            threads.append(gevent.spawn(get_timeline_data,account))
        gevent.joinall(threads)
        while not data.empty():
            result_data.append(data.get_nowait())
        return result_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号