Repository: spyder-ide/spyder

Issue:
Reports of Kernel Death are greatly exagerated
## Description of your problem

**What steps will reproduce the problem?**
1. launch a new Ipython console
2. during a few seconds, "kernel death" messages are displayed
   ![kernel_death_20160922](https://cloud.githubusercontent.com/assets/4312421/18758141/1df4e8f4-80f7-11e6-9554-bb1a383fec12.PNG)
3. all is going back in order without human intervention, but for 4 Kernel death message there are 4 "[1]" lines displayed in the new Ipython console
   ![kernel_death_20160922b](https://cloud.githubusercontent.com/assets/4312421/18758330/db1e6fb8-80f7-11e6-83d7-2de0f7a30da3.PNG)

**What is the expected output? What do you see instead?**
- no, or much less  reports of "Kernel Death"

**Please provide any additional information below**
- it's more frequent if the pc is slow or busy
## Versions and main components
- Spyder Version:3.0.0-master of 2016-09-21 ("b8")
- Python Version: any (3.4)
- Operating system: Windows 10
## Dependencies

Please go to the menu entry `Help > Optional Dependencies` (or
`Help > Dependencies`), press the button `Copy to clipboard`
and paste the contents below:
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  2.0.0b4 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.19.0rc1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
pyflakes >=0.6.0 :  1.3.0 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.6.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4-1 (OK)
sphinx >=0.6.6   :  1.4.6 (OK)
sympy >=0.7.3    :  1.0 (OK)



Discussion:
I have the same on 64bit Linux (Mint 18)

Spyder 3.0.0b7 installed via conda
Python 2.7.12 |Anaconda 4.1.1 (64-bit)| (default, Jul  2 2016, 17:42:40)
IPython 4.2.0 -- An enhanced Interactive Python.
jedi >=0.8.1     :  0.9.0 (OK)
matplotlib >=1.0 :  1.5.1 (OK)
nbconvert >=4.0  :  4.2.0 (OK)
numpy >=1.7      :  1.11.1 (OK)
pandas >=0.13.1  :  0.18.1 (OK)
pep8 >=0.6       :  1.7.0 (OK)
psutil >=0.3     :  4.3.0 (OK)
pyflakes >=0.5.0 :  1.2.3 (OK)
pygments >=2.0   :  2.1.3 (OK)
pylint >=0.25    :  1.5.4 (OK)
qtconsole >=4.2.0:  4.2.1 (OK)
rope >=0.9.4     :  0.9.4 (OK)
sphinx >=0.6.6   :  1.4.1 (OK)
sympy >=0.7.3    :  1.0 (OK)

Atleast in my case `spyder 3.0.0.b6` doesn't have this issue, but `spyder 3.0.0b7` and `spyder 3.0` both do. 

yes, the big architectural change (on the connexion to ipython kernel)  was merged after b6. https://github.com/spyder-ide/spyder/pull/2878

@ccordoba12 Hello everybody, im getting the same exact error. Happy to help. My understanding is that error is not very serious, right?

Yes, it isn't serious. We just need to find a way to prevent it :-)

Not serious? It renders Spyder unusable. I'd say that is serious. After several minutes, "Kernel died, restarting" returns.

What's interesting, is that I was using Spyder last night without a problem. Now today, this problem manifests. For both 3.0.0 and 3.0.1.

Actually, noticed an issue with distnoted process (runaway cpu usage) https://discussions.apple.com/thread/7290687?start=0&tstart=0 which may be related.
I rebooted and "kernel died, restarting" issue did not manifest...because of distnoted? or because I rebooted? Don't know yet. I'll respond with more info when/if this occurs again.

It is serious, I can't debug any program and the solution that you give, does not work to me. Another idea? Thanks

This is not Spyder's fault. This happens when your computer is slow to create a kernel (because it lacks enough RAM or it's undergoing high CPU usage, as @mrclary said before).

@ccordoba12 maybe if the time to generated de kernel was long as the time in the defauld configuration the error will fix 

Yep, the idea to solve this issue is to increase the time to check the kernel is up.

But this can't be made infinitely large :-) I think 6 secs is good enough (from the current 3 secs).

Please when we chance this time. I try to find this  time in spyder_kernel.py but it didn't appear

Maybe the loading of spyder itself is also slowing down things (time to load in windows cache all python objects).

would it be possible  to start (or start waiting) the kernel thing after the rest of spyder is well loaded ?

@ccordoba12 say somethig about time of wait for kernel of ipython. I think that the problem is on ipython console and not in spyder. I have the problem and i back to spyder 2.3.9 becouse 3.0 and 3.01 have this problem.

Here are some logs:

```
P500:~/Downloads$ spyder
Qt: Cannot set locale modifiers: 
void DBusMenuExporterPrivate::addAction(QAction*, int): Already tracking action "Project explorer" under id 124 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/spyder/utils/ipython/start_kernel.py", line 223, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/spyder/utils/ipython/start_kernel.py", line 196, in main
    from ipykernel.kernelapp import IPKernelApp
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/usr/local/lib/python2.7/dist-packages/ipykernel/connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir
  File "/home/lukeskywalker/.local/lib/python2.7/site-packages/IPython/__init__.py", line 48, in <module>
    from .core.application import Application
  File "/home/lukeskywalker/.local/lib/python2.7/site-packages/IPython/core/application.py", line 25, in <module>
    from IPython.core import release, crashhandler
  File "/home/lukeskywalker/.local/lib/python2.7/site-packages/IPython/core/crashhandler.py", line 28, in <module>
    from IPython.core import ultratb
  File "/home/lukeskywalker/.local/lib/python2.7/site-packages/IPython/core/ultratb.py", line 128, in <module>
    from IPython.utils.terminal import get_terminal_size
  File "/home/lukeskywalker/.local/lib/python2.7/site-packages/IPython/utils/terminal.py", line 22, in <module>
    from backports.shutil_get_terminal_size import get_terminal_size as _get_terminal_size
ImportError: No module named shutil_get_terminal_size
```

@livst, this is not the same error as the one reported here. For your problem, please see https://github.com/ipython/ipython/issues/9656


Resolving patch:
diff --git a/spyder/plugins/ipythonconsole.py b/spyder/plugins/ipythonconsole.py
--- a/spyder/plugins/ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole.py
@@ -1297,6 +1297,10 @@ def create_kernel_manager_and_kernel_client(self, connection_file):
         # Kernel client
         kernel_client = kernel_manager.client()
 
+        # Increase time to detect if a kernel is alive
+        # See Issue 3444
+        kernel_client.hb_channel.time_to_dead = 6.0
+
         return kernel_manager, kernel_client
 
     #------ Public API (for tabs) ---------------------------------------------


Test patch: