@@ -26,7 +26,8 @@ class EventManager(object):
2626
2727 This API is experimental in IPython 2.0, and may be revised in future versions.
2828 """
29- def __init__ (self , shell , available_events ):
29+
30+ def __init__ (self , shell , available_events , print_on_error = True ):
3031 """Initialise the :class:`CallbackManager`.
3132
3233 Parameters
@@ -35,9 +36,12 @@ def __init__(self, shell, available_events):
3536 The :class:`~IPython.core.interactiveshell.InteractiveShell` instance
3637 available_events
3738 An iterable of names for callback events.
39+ print_on_error:
40+ A boolean flag to set whether the EventManager will print a warning which a event errors.
3841 """
3942 self .shell = shell
4043 self .callbacks = {n :[] for n in available_events }
44+ self .print_on_error = print_on_error
4145
4246 def register (self , event , function ):
4347 """Register a new event callback.
@@ -88,7 +92,8 @@ def trigger(self, event, *args, **kwargs):
8892 try :
8993 func (* args , ** kwargs )
9094 except (Exception , KeyboardInterrupt ):
91- print ("Error in callback {} (for {}):" .format (func , event ))
95+ if self .print_on_error :
96+ print ("Error in callback {} (for {}):" .format (func , event ))
9297 self .shell .showtraceback ()
9398
9499# event_name -> prototype mapping
0 commit comments