Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too many files open when starting and stopping kernel repeatedly #4882

Closed
astrofrog opened this issue Jan 27, 2014 · 3 comments · Fixed by #4890
Closed

Too many files open when starting and stopping kernel repeatedly #4882

astrofrog opened this issue Jan 27, 2014 · 3 comments · Fixed by #4890
Milestone

Comments

@astrofrog
Copy link
Contributor

The following code:

from IPython.kernel import KernelManager

for i in range(1000):
    km = KernelManager()
    km.start_kernel(extra_arguments=['--pylab=inline'])
    kc = km.client()
    kc.start_channels()
    kc.stop_channels()
    km.shutdown_kernel(now=True)

causes the following exception after ~27 iterations:

Traceback (most recent call last):
  File "test_ipython.py", line 6, in <module>
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/IPython/kernel/manager.py", line 202, in start_kernel
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/IPython/kernel/connect.py", line 481, in write_connection_file
  File "/Users/tom/Library/Python/2.7/lib/python/site-packages/IPython/kernel/connect.py", line 110, in write_connection_file
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 187, in __init__
socket.error: [Errno 24] Too many open files

It looks like some file handles are not getting closed? I had a look and didn't see anything obvious. This is relevant for e.g. runipy because it starts and stops the kernel each time a different notebook is run.

(also, the error occurs even if I set now=False).

@ellisonbg
Copy link
Member

I can reproduce. It causes and fatal error in libzmq for me after 21 iterations.

@minrk
Copy link
Member

minrk commented Jan 27, 2014

Should be fixed by #4890.

@minrk
Copy link
Member

minrk commented Jan 27, 2014

I should also note that OS X has an unusually low FD limit (256 by default, while most other systems use 1024). You can easily push this limit up with ulimit -n 1024.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants