当前位置:首页 > python > 正文内容

python 多进程

root4年前 (2022-01-28)python1811
from multiprocessing import Pool

def test(x,y):
    return x+y
# 创建一个多进程池,最大8进程
pool = Pool(processes=8)
args = [(1,3),(2,4),(3,5)]
pool.map(test,args)
pool.close()
pool.join()


扫描二维码推送至手机访问。

版权声明:本文由一叶知秋发布,如需转载请注明出处。

本文链接:https://zhiqiu.top/?id=215

标签: python多进程
分享给朋友:

相关文章

cmd启动python交互模式 出现UnicodeDecodeError: 'gbk' codec can't decode byte 0x9a in position 533

这是因为在python交互模式的中输出了中文,且是个输出被记录在.python_history中删除历史记录文件C:\Users\Administrator\.python_history...

获取大文件的MD5值

(, )os.path.(, )logger.()         os.path.(, )logger.()  &...

Python的多线程并发限制

maxConnections connection_lock (maxConnections)在开启线程前执行connection_lock.acquire()线程执行结束执行connection_lock.releas...

python 调用linux命令 subprocess.popen

import subprocesscommd = "echo 123"p1 = subprocess.Popen(commd, shell=True, stdout=subprocess.PIPE, stder...

python进行远程ssh连接的pexpect模块

from pexpect import pxssh s=pxssh.pxssh() s.login(host, user, password) s.sendline(cmd) s.p...

Python  os.system 和subprocess.popen 并发执行linux的性能对比

Python os.system 和subprocess.popen 并发执行linux的性能对比

os subprocess multiprocessing.dummy Pool ThreadPool command_list [] ()os.() start_time =&...