
python多进程
默默前行的旅者
记录过程
展开
-
多进程使用(根据日志统计IP访问次数)
import os import time from concurrent.futures import ProcessPoolExecutor from multiprocessing import Manager def task(file_name, count_dict): ip_set = set() total_count = 0 ip_count = 0 file_path = os.path.join("file", file_name) file原创 2021-12-09 20:58:31 · 2545 阅读 · 0 评论 -
subprocess.Popen使用及wait()的简单描述
写爬虫项目时,为防止某一个爬虫挂了影响到其他爬虫的进行,所以对爬虫单独开启一个进程,然后设置每个爬虫时间范围,如果超出了这个时间,则将该爬虫的进程kill掉,这样可以不影响其他爬虫任务的进行。使用subprocess模块 ```python # scrapy crawl *** -a taskid=*** spider_name = gbl.gConfig.get('spiders_info').get('gxmobile').get(spider_type) cmd = [env_pat原创 2020-07-09 14:26:49 · 6476 阅读 · 0 评论