break/interrupt a time.sleep() in python

后端 未结 6 1433
猫巷女王i
猫巷女王i 2020-12-01 03:30

I need to break from time.sleep() using ctrl c.

While 1:
    time.sleep(60)

In the above code when the control enters time.sleep function a

6条回答
  •  独厮守ぢ
    2020-12-01 03:55

    I tried your code with python versions 2.5, 2.6, 3 under Linux and all throw "KeyboardInterrupt" exception when hitting CTRL-C.

    Maybe some exception handling catches the Interrupt or your problem is like this: Why is KeyboardInterrupt not working in python?

提交回复
热议问题