Open eyalfir opened 10 years ago
Confirmed.
This also happens when you stop the ipython kernel, and use :IPython
again.
The errors occurs in this line
fullpath = find_connection_file(s.lstrip().rstrip())
Find_connection_file is IPython.lib.kernel.find_connection_file. The error occurs, in my observations, only when
s.lstrip().rstrip() == ''
I've implemented my own variant of "find_connection_file" the second time as a wolkaround:
global km, kc, send, Empty, kernel_dir
# I added this to circumvent a bug in python 2.7.3 where find_connection_file('')
# fails if invoked after kc.start_channels() - ef
import os
if not s and not kernel_dir:
s = find_connection_file("")
kernel_dir = os.path.dirname(s)
elif not s and kernel_dir:
files = [os.path.join(kernel_dir,x) for x in os.listdir(kernel_dir)]
stats = {}
for f in files:
stats[f] = os.stat(f)
max_mtime = max([x.st_mtime for x in stats.values()])
options = [x for x,y in stats.items() if y.st_mtime==max_mtime]
if len(options)==1:
s = options[0]
print s
#### end of change
this work-around looks for the kernel connection json with the most recent creation json in the same directory that the first call to :IPython found.
This bug is really annoying -- when my IPython kernel dies I have to restart vim. Can you please fix this?
@Eyalfir Thanks for bringing this up! I spend quite some time looking for a reasons why I can't connect to the ipython console even through it worked at first. Did you consider opening a PR with your solution?
After restarting the ipython kernel I try reconnecting with :IPython I get an error from find_connection_file: Traceback (most recent call last): File "", line 1, in
File "", line 117, in km_from_string
File "/usr/local/lib/python2.7/dist-packages/IPython/kernel/connect.py", line 202, in find_connection_file
app = IPApp.instance()
File "/usr/local/lib/python2.7/dist-packages/IPython/config/configurable.py", line 360, in instance
'%s are being created.' % cls.name
IPython.config.configurable.MultipleInstanceError: Multiple incompatible subclass instances of BaseIPythonApplication are being crea
ted.