Show More
@@ -14,6 +14,7 b' in the IPython notebook front-end.' | |||||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 | from contextlib import contextmanager |
|
15 | from contextlib import contextmanager | |
16 |
|
16 | |||
|
17 | from IPython.core.getipython import get_ipython | |||
17 | from IPython.kernel.comm import Comm |
|
18 | from IPython.kernel.comm import Comm | |
18 | from IPython.config import LoggingConfigurable |
|
19 | from IPython.config import LoggingConfigurable | |
19 | from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple |
|
20 | from IPython.utils.traitlets import Unicode, Dict, Instance, Bool, List, Tuple | |
@@ -33,7 +34,11 b' class CallbackDispatcher(LoggingConfigurable):' | |||||
33 | try: |
|
34 | try: | |
34 | local_value = callback(*args, **kwargs) |
|
35 | local_value = callback(*args, **kwargs) | |
35 | except Exception as e: |
|
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 | else: |
|
42 | else: | |
38 | value = local_value if local_value is not None else value |
|
43 | value = local_value if local_value is not None else value | |
39 | return value |
|
44 | return value | |
@@ -54,6 +59,18 b' class CallbackDispatcher(LoggingConfigurable):' | |||||
54 | elif not remove and callback not in self.callbacks: |
|
59 | elif not remove and callback not in self.callbacks: | |
55 | self.callbacks.append(callback) |
|
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 | class Widget(LoggingConfigurable): |
|
75 | class Widget(LoggingConfigurable): | |
59 | #------------------------------------------------------------------------- |
|
76 | #------------------------------------------------------------------------- | |
@@ -241,6 +258,7 b' class Widget(LoggingConfigurable):' | |||||
241 | value != self._property_lock[1] |
|
258 | value != self._property_lock[1] | |
242 |
|
259 | |||
243 | # Event handlers |
|
260 | # Event handlers | |
|
261 | @_show_traceback | |||
244 | def _handle_msg(self, msg): |
|
262 | def _handle_msg(self, msg): | |
245 | """Called when a msg is received from the front-end""" |
|
263 | """Called when a msg is received from the front-end""" | |
246 | data = msg['content']['data'] |
|
264 | data = msg['content']['data'] |
General Comments 0
You need to be logged in to leave comments.
Login now