作用:Python多进程处理模块,解决threading模块不能使用多个CPU内核,避免Python GIL(全局解释器)带来的计算瓶颈。

1、开启多进程的简单示例,处理函数无带参数

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import multiprocessing

def worker():
    print('工作中')

if __name__ == '__main__':
    for i in range(5):
        p = multiprocessing.Process(target=worker)
        p.start()
multiprocessing_simple.py

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-01-16
  • 2021-11-24
  • 2021-11-22
  • 2022-02-14
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2022-12-23
  • 2022-02-26
  • 2022-12-23
  • 2022-01-24
  • 2021-06-03
相关资源
相似解决方案