manrajgrover/halo

iPython notebook keyboard interrupt breaks cell when using Halo

Open

#35 opened on Dec 30, 2017

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Python (149 forks)github user discovery
bughacktoberfestipythonup-for-grabs

Repository metrics

Stars
 (3,022 stars)
PR merge metrics
 (PR metrics pending)

Description

Description

Currently, in an iPython notebook, if a user does not handle keyboard interrupt and the spinner is running, a KeyboardInterrupt is thrown but the spinner keeps spinning.

System settings

  • Operating System: MacOS
  • Terminal in use: iTerm 2
  • Python version: 2.7.10
  • Halo version: 0.0.8

Error

Expected behaviour

In [5]: import time
   ...: import random
   ...:
   ...: spinner.start()
   ...: for i in range(100):
   ...:     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
   ...:     time.sleep(random.random())
   ...: spinner.succeed('Downloaded dataset.zip')
   ...:
⠹ 4% Downloaded dataset.zip^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-5-81a625f23371> in <module>()
      5 for i in range(100):
      6     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
----> 7     time.sleep(random.random())
      8 spinner.succeed('Downloaded dataset.zip')
      9

KeyboardInterrupt:

⠼ 4% Downloaded

Steps to recreate

Following snippet should recreate the error.

In [1]: from halo import Halo

In [2]: spinner = Halo(text='Downloading dataset.zip', spinner='dots')

In [3]: import time
   ...: import random
   ...:
   ...: spinner.start()
   ...: for i in range(100):
   ...:     spinner.text = '{0}% Downloaded dataset.zip'.format(i)
   ...:     time.sleep(random.random())
   ...: spinner.succeed('Downloaded dataset.zip')

People to notify

@ManrajGrover

Contributor guide