File tree 1 file changed +15
-1
lines changed 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -108,8 +108,13 @@ def _backend_selection():
108
108
from matplotlib .backends import pylab_setup
109
109
_backend_mod , new_figure_manager , draw_if_interactive , _show = pylab_setup ()
110
110
111
+ _BASE_DH = None
112
+ _IP_REGISTERED = False
113
+
111
114
112
115
def install_repl_displayhook ():
116
+ global _BASE_DH
117
+ global _IP_REGISTERED
113
118
114
119
class _NotIPython (Exception ):
115
120
pass
@@ -122,16 +127,25 @@ class _NotIPython(Exception):
122
127
if ip is None :
123
128
raise _NotIPython ()
124
129
130
+ if _IP_REGISTERED :
131
+ return
132
+
125
133
# IPython >= 2
126
134
try :
127
135
ip .events .register ('post_execute' , draw_all )
128
136
except AttributeError :
129
137
# IPython 1.x
130
138
ip .register_post_execute (draw_all )
139
+ finally :
140
+ _IP_REGISTERED = True
131
141
132
142
# import failed or ipython is not running
133
143
except (ImportError , _NotIPython ):
134
- dh = sys .displayhook
144
+
145
+ if _BASE_DH is not None :
146
+ return
147
+
148
+ dh = _BASE_DH = sys .displayhook
135
149
136
150
def displayhook (* args ):
137
151
dh (* args )
You can’t perform that action at this time.
0 commit comments