MCPcopy Create free account
hub / github.com/ipython/ipython / ignore_keyboardinterrupts

Function ignore_keyboardinterrupts

IPython/terminal/pt_inputhooks/wx.py:11–24  ·  view source on GitHub ↗

Decorator which causes KeyboardInterrupt exceptions to be ignored during execution of the decorated function. This is used by the inputhook functions to handle the event where the user presses CTRL+C while IPython is idle, and the inputhook loop is running. In this case, we want to

(func)

Source from the content-addressed store, hash-verified

9
10
11def ignore_keyboardinterrupts(func):
12 """Decorator which causes KeyboardInterrupt exceptions to be ignored during
13 execution of the decorated function.
14
15 This is used by the inputhook functions to handle the event where the user
16 presses CTRL+C while IPython is idle, and the inputhook loop is running. In
17 this case, we want to ignore interrupts.
18 """
19 def wrapper(*args, **kwargs):
20 try:
21 func(*args, **kwargs)
22 except KeyboardInterrupt:
23 pass
24 return wrapper
25
26
27@ignore_keyboardinterrupts

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected