
import sys
import os
import time
sys.path.append(os.path.dirname(sys.path[0]))  # 上级目录
from multiprocessing import Pool
from amazon_spider.asin_keepa_data import KeepApi
# from amazon_spider.asin_keepa_data_copy import KeepApi


def long_time_task(site,proxy_name):
    print(site)
    async_asin_us = KeepApi(site, proxy_name=proxy_name)
    async_asin_us.run()

if __name__ == '__main__':
    site_list = ['us']
    proxy_name = None
    for site in site_list:
            p = Pool(30)
            for i in range(30):
                time.sleep(0.2)
                p.apply_async(long_time_task, args=(site,proxy_name))
            # 执行该方法后不能继续添加新的Process
            p.close()
            # 等待所有子进程执行完毕
            p.join()
            print('所有进程运行完毕！')

