Show More
@@ -14,6 +14,7 b' in the IPython notebook front-end.' | |||
|
14 | 14 | #----------------------------------------------------------------------------- |
|
15 | 15 | from contextlib import contextmanager |
|
16 | 16 | |
|
17 | from IPython.core.getipython import get_ipython | |
|
17 | 18 | from IPython.kernel.comm import Comm |
|
18 | 19 | from IPython.config import LoggingConfigurable |
|
19 | 20 | from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple |
@@ -33,7 +34,11 b' class CallbackDispatcher(LoggingConfigurable):' | |||
|
33 | 34 | try: |
|
34 | 35 | local_value = callback(*args, **kwargs) |
|
35 | 36 | except Exception as e: |
|
36 | self.log.warn("Exception in callback %s: %s", callback, e) | |
|
37 | ip = get_ipython() | |
|
38 | if ip is None: | |
|
39 | self.log.warn("Exception in callback %s: %s", callback, e, exc_info=True) | |
|
40 | else: | |
|
41 | ip.showtraceback() | |
|
37 | 42 | else: |
|
38 | 43 | value = local_value if local_value is not None else value |
|
39 | 44 | return value |
@@ -54,6 +59,18 b' class CallbackDispatcher(LoggingConfigurable):' | |||
|
54 | 59 | elif not remove and callback not in self.callbacks: |
|
55 | 60 | self.callbacks.append(callback) |
|
56 | 61 | |
|
62 | def _show_traceback(method): | |
|
63 | """decorator for showing tracebacks in IPython""" | |
|
64 | def m(self, *args, **kwargs): | |
|
65 | try: | |
|
66 | return(method(self, *args, **kwargs)) | |
|
67 | except Exception as e: | |
|
68 | ip = get_ipython() | |
|
69 | if ip is None: | |
|
70 | self.log.warn("Exception in widget method %s: %s", method, e, exc_info=True) | |
|
71 | else: | |
|
72 | ip.showtraceback() | |
|
73 | return m | |
|
57 | 74 | |
|
58 | 75 | class Widget(LoggingConfigurable): |
|
59 | 76 | #------------------------------------------------------------------------- |
@@ -241,6 +258,7 b' class Widget(LoggingConfigurable):' | |||
|
241 | 258 | value != self._property_lock[1] |
|
242 | 259 | |
|
243 | 260 | # Event handlers |
|
261 | @_show_traceback | |
|
244 | 262 | def _handle_msg(self, msg): |
|
245 | 263 | """Called when a msg is received from the front-end""" |
|
246 | 264 | data = msg['content']['data'] |
General Comments 0
You need to be logged in to leave comments.
Login now