python os.fork()可以创建多少个进程

编程入门 行业动态 更新时间:2024-10-10 07:26:15
本文介绍了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()可以创建多少个进程

本文发布于:2023-07-06 07:46:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1047479.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多少个   进程   python   os   fork

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!