Python实战计划学习笔记(11)使用多进程

2016-09-02  本文已影响0人  如恒河沙

心得

进程池代码

from multiprocessing import Pool
from channel_extract import channel_list
from page_parsing import get_links_from

def get_all_links_from(channel):
    for num in range(1,101):
        get_links_from(channel,num)

if __name__ == '__main__':
    #创建进程池
    pool = Pool()
    pool.map(get_all_links_from,channel_list.split())

数据库条目计数器代码

import time
from page_parsing import url_list

while True:
    print(url_list.find().count())
    time.sleep(5)
上一篇 下一篇

猜你喜欢

热点阅读