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?