Permalink
Browse files

explicit for-loop in cleanup_kernels

makes single-iteration clearer than while loop, as reviewed by @fperez.
  • Loading branch information...
minrk committed Jan 6, 2012
1 parent 14bb294 commit 0f2a7ee3f4c1756ca8cee30c428b953fa8ea0fb0
Showing with 3 additions and 2 deletions.
  1. +3 −2 IPython/frontend/html/notebook/notebookapp.py
@@ -367,8 +367,9 @@ def cleanup_kernels(self):
"""
self.log.info('Shutting down kernels')
km = self.kernel_manager
- while km.kernel_ids:
- km.kill_kernel(km.kernel_ids[0])
+ # copy list, since kill_kernel deletes keys
+ for kid in list(km.kernel_ids):
+ km.kill_kernel(kid)
def start(self):
ip = self.ip if self.ip else '[all ip addresses on your system]'

2 comments on commit 0f2a7ee

@fperez

This comment has been minimized.

Show comment
Hide comment
@fperez

fperez Jan 6, 2012

I'm glad the function is called kill_kernel and not kill, otherwise that last line would read pretty darkly ;) Thanks!

I'm glad the function is called kill_kernel and not kill, otherwise that last line would read pretty darkly ;) Thanks!

@minrk

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Jan 6, 2012

Owner

Indeed it would. I hadn't seen that.

Owner

minrk replied Jan 6, 2012

Indeed it would. I hadn't seen that.

Please sign in to comment.