Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1608095

Browse files
committed
Fixed single-shot timers in nbagg backend
1 parent 5d9245d commit 1608095

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/matplotlib/backends/backend_nbagg.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# lib/matplotlib/backends/web_backend/nbagg_uat.ipynb to help verify
44
# that changes made maintain expected behaviour.
55

6+
import datetime
67
from base64 import b64encode
78
import json
89
import io
@@ -171,7 +172,6 @@ def clearup_closed(self):
171172

172173
class TimerTornado(TimerBase):
173174
def _timer_start(self):
174-
import datetime
175175
self._timer_stop()
176176
if self._single:
177177
ioloop = tornado.ioloop.IOLoop.instance()
@@ -182,10 +182,15 @@ def _timer_start(self):
182182
self._timer = tornado.ioloop.PeriodicCallback(
183183
self._on_timer,
184184
self.interval)
185-
self._timer.start()
185+
self._timer.start()
186186

187187
def _timer_stop(self):
188-
if self._timer is not None:
188+
if self._timer is None:
189+
return
190+
elif self._single:
191+
ioloop = tornado.ioloop.IOLoop.instance()
192+
ioloop.remove_timeout(self._timer)
193+
else:
189194
self._timer.stop()
190195
self._timer = None
191196

0 commit comments

Comments
 (0)