为什么jupyter笔记本电脑的子过程结果不同?
我正在尝试了解subprocess
模块在Linux上的Jupyter笔记本上运行时的行为。我正在使用subprocess
来捕获Linux上的开放文件限制的数量。在终端上如下:
ulimit -n
这给了我1024的限制。
如果我使用subprocess
从命令行上的python调用此,则我仍然可以预期的是1024:
from subprocess import call
call("ulimit -n", shell = True)
但是,如果我运行此操作从jupyter笔记本电脑中,我得到4096。
如果我使用Resource
模块来找出软限制,也可以合作。以下内容从命令行提供了1024,但是jupyter笔记本中的4096。
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
soft
我(可能是幼稚的)假设是subprocess.call
应该给我相同的结果,而不管我从哪里调用。谁能解释什么原因导致差异?
I am trying to understand the behaviour of the subprocess
module when it is running on a Jupyter notebook on linux. I am using subprocess
to capture the number of open files limit on Linux. On the terminal this is as follows:
ulimit -n
This gives me a limit of 1024.
If I call this using subprocess
from Python on the command line, I still get 1024, as expected:
from subprocess import call
call("ulimit -n", shell = True)
However, if I run this from a Jupyter notebook, I get 4096.
The same also holds if I use the resource
module to find out the soft limit. The following gives me 1024 from the command line, but 4096 from a Jupyter notebook.
import resource
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
soft
My (possibly naive) assumption is that subprocess.call
should give me the same results regardless of where I am calling it from. Can anyone explain what causes the difference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论