Can't Interrupt Kernel

2,710 views
Skip to first unread message

Dave Hirschfeld

unread,
Jun 6, 2014, 7:38:10 AM6/6/14
to spyd...@googlegroups.com
In the IPython console in spyder the Kernel interrupt doesn't seem to be working. The following code will put you in an infinite, unbreakable loop:

In [1]: from time import sleep


In [2]: while True:

   ...: sleep(2)

   ...:



Clicking Ctrl-C has no effect, nor does using the "Interrupt Kernel" button on the top -right of the IPython console pane.
By contrast in the QtConsole itself I observe the expected behaviour when pressing Ctrl-C:


In [1]: from time import sleep


In [2]: while True:

   ...: sleep(2)

   ...:

---------------------------------------------------------------------------

KeyboardInterrupt Traceback (most recent call last)

<ipython-input-2-4fdabcf7d3fc> in <module>()

1 while True:

----> 2 sleep(2)

3


KeyboardInterrupt:


In [3]: from IPython import sys_info; print(sys_info())

{'commit_hash': '681fd77',

'commit_source': 'installation',

'default_encoding': 'cp1252',

'ipython_path': 'C:\\dev\\bin\\Anaconda\\lib\\site-packages\\IPython',

'ipython_version': '2.1.0',

'os_name': 'nt',

'platform': 'Windows-7-6.1.7601-SP1',

'sys_executable': 'C:\\dev\\bin\\Anaconda\\python.exe',

'sys_platform': 'win32',

'sys_version': '2.7.5 |Anaconda 1.9.2 (64-bit)| (default, Jul 1 2013, 12:37:52) [MSC v.1500 64 bit (AMD64)]'}



Suspiciously, when I start an IPython console in the Kernel tab in the Console pane I see the following message:


NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.


To exit, you will have to explicitly quit this process, by either sending

"quit" from a client, or using Ctrl-\ in UNIX-like environments.


To read more about this, see https://github.com/ipython/ipython/issues/2049



To connect another client to this kernel, use:

    --existing kernel-11532.json



Since this works in the IPython QtConsole would it be possible to get it working in Spyder as well?


As it is currently I'm doing a lot of IPython.parallel work where I need to be able to interrupt a parallel calculation (a loop, waiting on asynchronous results) and it's very annoying to lose my session if I want to do so.


Thanks,

Dave


Carlos Córdoba

unread,
Jun 11, 2014, 10:51:23 PM6/11/14
to spyd...@googlegroups.com
Hi Dave,

This is working for me with IPython 2.1.0. Are you using IPython master?


Cheers,
Carlos

El 06/06/14 06:38, Dave Hirschfeld escribió:
--
You received this message because you are subscribed to the Google Groups "spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spyderlib+...@googlegroups.com.
To post to this group, send email to spyd...@googlegroups.com.
Visit this group at http://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Dave Hirschfeld

unread,
Jun 16, 2014, 3:38:25 AM6/16/14
to spyd...@googlegroups.com

On Thursday, 12 June 2014 03:51:23 UTC+1, Carlos Córdoba wrote:
Hi Dave,

This is working for me with IPython 2.1.0. Are you using IPython master?


Cheers,
Carlos

I'm running 2.1 also. I've since upgraded spyder to the latest master and rebooted my PC and can't seem to reproduce the issue either. Sorry for the noise...


-Dave 

Dave Hirschfeld

unread,
Jun 17, 2014, 8:18:58 AM6/17/14
to spyd...@googlegroups.com


On Thursday, 12 June 2014 03:51:23 UTC+1, Carlos Córdoba wrote:
Hi Dave,

This is working for me with IPython 2.1.0. Are you using IPython master?


Cheers,
Carlos


I've managed to reproduce it!

The trick is that it always works in a newly opened IPython console. It's only after you Restart the console that you lose the ability to break out of any loops with Ctrl-C.

I hit this problem because I'm always hitting Ctrl-. to restart my console as it's quicker and more convenient than opening a new console.

Note that this doesn't occur in the qtconsole for me.

Let me know if you can repro the problem!

Thanks,
Dave


In [1]: from time import sleep

   ...: while True:

   ...: sleep(2)

   ...:

---------------------------------------------------------------------------

KeyboardInterrupt Traceback (most recent call last)

<ipython-input-1-0b0776baa1cf> in <module>()

1 from time import sleep

2 while True:

----> 3 sleep(2)

4


KeyboardInterrupt:


Restarting kernel...



In [1]: from time import sleep

   ...: while True:

   ...: sleep(2)

---------------------------------------------------------------------------

KeyboardInterrupt Traceback (most recent call last)

<ipython-input-1-96b4b67498f8> in <module>()

1 from time import sleep

2 while True:

----> 3 sleep(2)


KeyboardInterrupt:


In [1]:






Carlos Córdoba

unread,
Jun 19, 2014, 6:00:13 PM6/19/14
to spyd...@googlegroups.com
Hi,

Very good catch! Please open an issue so we don't forget to address it. I'll try to fix for 2.3.1.


Cheers,
Carlos

El 17/06/14 07:18, Dave Hirschfeld escribió:

Dave Hirschfeld

unread,
Jun 21, 2014, 5:54:06 AM6/21/14
to spyd...@googlegroups.com

On Thursday, 19 June 2014 23:00:13 UTC+1, Carlos Córdoba wrote:
Hi,

Very good catch! Please open an issue so we don't forget to address it. I'll try to fix for 2.3.1.


Cheers,
Carlos

El 17/06/14 07:18, Dave Hirschfeld escribió:


On Thursday, 12 June 2014 03:51:23 UTC+1, Carlos Córdoba wrote:
Hi Dave,

This is working for me with IPython 2.1.0. Are you using IPython master?


Cheers,
Carlos


I've managed to reproduce it!

The trick is that it always works in a newly opened IPython console. It's only after you Restart the console that you lose the ability to break out of any loops with Ctrl-C.

I hit this problem because I'm always hitting Ctrl-. to restart my console as it's quicker and more convenient than opening a new console.

Note that this doesn't occur in the qtconsole for me.

Let me know if you can repro the problem!

Thanks,
Dave

Done!

-Dave 
Reply all
Reply to author
Forward
0 new messages