8000 Fix single-shot timers in nbagg backend by joferkington · Pull Request #4892 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix single-shot timers in nbagg backend #4892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 12, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
8000
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixed single-shot timers in nbagg backend
  • Loading branch information
joferkington committed Aug 9, 2015
commit 1608095e697e7af19306892070df87128ae14878
11 changes: 8 additions & 3 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# lib/matplotlib/backends/web_backend/nbagg_uat.ipynb to help verify
# that changes made maintain expected behaviour.

import datetime
from base64 import b64encode
import json
import io
Expand Down Expand Up @@ -171,7 +172,6 @@ def clearup_closed(self):

class TimerTornado(TimerBase):
def _timer_start(self):
import datetime
self._timer_stop()
if self._single:
ioloop = tornado.ioloop.IOLoop.instance()
Expand All @@ -182,10 +182,15 @@ def _timer_start(self):
self._timer = tornado.ioloop.PeriodicCallback(
self._on_timer,
self.interval)
self._timer.start()
self._timer.start()

def _timer_stop(self):
if self._timer is not None:
if self._timer is None:
return
elif self._single:
ioloop = tornado.ioloop.IOLoop.instance()
ioloop.remove_timeout(self._timer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should set self._timer to None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed in 825157f

else:
self._timer.stop()
self._timer = None

Expand Down
0