Show More
@@ -14,6 +14,7 b' events and the arguments which will be passed to them.' | |||||
14 | """ |
|
14 | """ | |
15 |
|
15 | |||
16 | from functools import wraps |
|
16 | from functools import wraps | |
|
17 | from inspect import isfunction | |||
17 | try: |
|
18 | try: | |
18 | from inspect import getfullargspec |
|
19 | from inspect import getfullargspec | |
19 | except: |
|
20 | except: | |
@@ -79,10 +80,10 b' class EventManager(object):' | |||||
79 | raise TypeError('Need a callable, got %r' % function) |
|
80 | raise TypeError('Need a callable, got %r' % function) | |
80 |
|
81 | |||
81 | callback_proto = available_events.get(event) |
|
82 | callback_proto = available_events.get(event) | |
82 |
if ( |
|
83 | if (isfunction(callback_proto) and isfunction(function) and | |
83 | len(getfullargspec(callback_proto).args) > 0 and |
|
84 | len(getfullargspec(callback_proto).args) > 0 and | |
84 | len(getfullargspec(function).args) == 0): |
|
85 | len(getfullargspec(function).args) == 0): | |
85 |
# `callback_proto` |
|
86 | # `callback_proto` has args but `function` does not, so a | |
86 | # compatibility wrapper is needed. |
|
87 | # compatibility wrapper is needed. | |
87 | self.callbacks[event].append(_compatibility_wrapper_for(function)) |
|
88 | self.callbacks[event].append(_compatibility_wrapper_for(function)) | |
88 | else: |
|
89 | else: |
@@ -70,11 +70,9 b' argument, even though the actual result is not yet available.' | |||||
70 | post_run_cell |
|
70 | post_run_cell | |
71 | ------------- |
|
71 | ------------- | |
72 |
|
72 | |||
73 | ``post_run_cell`` runs after interactive execution. |
|
73 | ``post_run_cell`` runs after interactive execution (e.g. a cell in a notebook). | |
74 | It can be used to cleanup or notify or perform operations on any side effects |
|
74 | It can be used to cleanup or notify or perform operations on any side effects produced during execution. | |
75 | produced during execution. |
|
75 | For instance, the inline matplotlib backend uses this event to display any figures created but not explicitly displayed during the course of the cell. | |
76 | For instance, the inline matplotlib backend uses this event to display any |
|
|||
77 | figures created but not explicitly displayed during the course of the cell. |
|
|||
78 | The object which will be returned as the execution result is provided as an |
|
76 | The object which will be returned as the execution result is provided as an | |
79 | argument. |
|
77 | argument. | |
80 |
|
78 | |||
@@ -84,20 +82,6 b' post_execute' | |||||
84 | The same as ``pre_execute``, ``post_execute`` is like ``post_run_cell``, |
|
82 | The same as ``pre_execute``, ``post_execute`` is like ``post_run_cell``, | |
85 | but fires for *all* executions, not just interactive ones. |
|
83 | but fires for *all* executions, not just interactive ones. | |
86 |
|
84 | |||
87 | finally_run_cell |
|
|||
88 | ------------- |
|
|||
89 |
|
||||
90 | ``finally_run_cell`` is like ``post_run_cell``, but fires after *all* executions |
|
|||
91 | (even when, for example, a ``SyntaxError`` was raised). |
|
|||
92 | Additionally, the execution result is provided as an argument. |
|
|||
93 |
|
||||
94 | finally_execute |
|
|||
95 | ------------ |
|
|||
96 |
|
||||
97 | ``finally_execute`` is like ``post_execute``, but fires after *all* executions |
|
|||
98 | (even when, for example, a ``SyntaxError`` was raised). |
|
|||
99 | Additionally, the execution result is provided as an argument. |
|
|||
100 |
|
||||
101 |
|
85 | |||
102 | .. seealso:: |
|
86 | .. seealso:: | |
103 |
|
87 |
General Comments 0
You need to be logged in to leave comments.
Login now