python os.fork()可以创建多少个进程 [英] how many processes can be created with python os.fork()

查看:44
本文介绍了python os.fork()可以创建多少个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在下面这样做:

for i in range(10000):
    os.fork()

这是怎么回事?我只是想了解os.fork()可以在linux中创建多少个进程,如果它像windows一样,只能创建大约2000个进程,那么接下来的8000个进程又会如何呢?
谢谢.

What's going on? don't consider reaping.. I just wanna know about os.fork() can make how much processes in linux, if it 's just like windows, only can make about 2000 processes, how the next 8000 processes will do?
Thanks.

推荐答案

os.fork()产生一个新的OS级进程.数量的任何限制都不取决于Python,而是取决于操作系统.根据这个先前的问题,在Linux上,您可以找到有关以下任何软件的信息-通过查看以下内容对此施加了限制:

os.fork() spawns a new OS-level process. Any limits on the number of those aren't dependent on Python, but on the operating system. According to this previous question, on Linux you can find out about any software-imposed constraints on that by looking at:

cat /proc/sys/kernel/pid_max

,但是/etc/security/limits.conf 可能会进一步限制它.如果没有立即打到您,那么您最终将遇到可用硬件资源的问题-您的代码是,以及普通的拒绝服务攻击类型(将任何软件对进程数的限制都设置为避免这种攻击).

but that might be further restrained by /etc/security/limits.conf. If those don't hit you first, you will eventually run into problems with available hardware resources - your code is a fork bomb, and type of trivial denial of service attack (any software limits on the number of processes are set to avoid this kind of attack).

这篇关于python os.fork()可以创建多少个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆