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
评论列表
文章目录