8000 Address @pelson's comments in the PR. · matplotlib/matplotlib@d7d6f15 · GitHub
[go: up one dir, main page]

Skip to content

Commit d7d6f15

Browse files
committed
Address @pelson's comments in the PR.
1 parent 25ff2f7 commit d7d6f15

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/matplotlib/backends/backend_webagg.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,10 @@ def remove_web_socket(self, web_socket):
295295
self.web_sockets.remove(web_socket)
296296

297297
def refresh_all(self):
298-
if len(self.web_sockets):
298+
if self.web_sockets:
299299
diff = self.canvas.get_diff_image()
300300
for s in self.web_sockets:
301-
s.send_image(diff)
301+
s.send_diff_image(diff)
302302

303303
def send_event(self, event_type, **kwargs):
304304
for s in self.web_sockets:
@@ -488,6 +488,13 @@ def on_message(self, message):
488488
if message['type'] == 'supports_binary':
489489
self.supports_binary = message['value']
490490
elif message['type'] == 'ack':
491+
# Network latency tends to decrease if traffic is
492+
# flowing in both directions. Therefore, the browser
493+
# sends back an "ack" message after each image frame
494+
# is received. This could also be used as a simple
495+
# sanity check in the future, but for now the
496+
# performance increase is enough to justify it, even
497+
# if the server does nothing with it.
491498
pass
492499
else:
493500
canvas = Gcf.get_fig_manager(self.fignum).canvas
@@ -498,7 +505,7 @@ def send_event(self, event_type, **kwargs):
498505
payload.update(kwargs)
499506
self.write_message(json.dumps(payload))
500507

501-
def send_image(self, diff):
508+
def send_diff_image(self, diff):
502509
if self.supports_binary:
503510
self.write_message(diff, binary=True)
504511
else:

0 commit comments

Comments
 (0)
0