0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【備忘録】multiprocessとmultiprocessingの違いについて

Posted at

multiprocess

multiprocessing(Pythonの標準ライブラリ)を改良したサードパーティライブラリ
色々便利になっているらしい。

違い

種々あるらしいので、見つけ次第追記

  • multiprocessは関数内関数を引数に持つことができる。
sample.py
from multiprocess import Pool
import multiprocess as mp # multiprocessingと競合する。

def crawl(urls):
    def scrape_detail_page():
        '''
            詳細ページをスクレイピング
        '''
        # スクレイピング内容をサーバーに突っ込む処理
        
        return None

    # 並列処理
    cpu_num = mp.cpu_count()  
    pool = Pool(processes=cpu_num)
    
    with tqdm(total=max_page) as page:
        for _ in pool.imap_unordered(request_process, range(1, max_page+1)):
            page.update(1)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?