From 8cb8124f794f78ab1246c4c1968c2076ff72fdde Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 21 Aug 2019 04:53:48 +0000 Subject: [PATCH] simplify: KeyError should be rare git-svn-id: https://xpra.org/svn/Xpra/trunk@23550 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/server/window/window_source.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xpra/server/window/window_source.py b/src/xpra/server/window/window_source.py index 9cf541e0e6..cff582d521 100644 --- a/src/xpra/server/window/window_source.py +++ b/src/xpra/server/window/window_source.py @@ -2138,15 +2138,15 @@ def damage_packet_acked(self, damage_packet_sequence, width, height, decode_time self.statistics.client_decode_time.append((monotonic_time(), width*height, decode_time)) elif decode_time<0: self.client_decode_error(decode_time, message) - pending = self.statistics.damage_ack_pending.get(damage_packet_sequence) - if pending is None: + try: + pending = self.statistics.damage_ack_pending.pop(damage_packet_sequence) + except KeyError: log("cannot find sent time for sequence %s", damage_packet_sequence) return - del self.statistics.damage_ack_pending[damage_packet_sequence] gs = self.global_statistics start_send_at, _, start_bytes, end_send_at, end_bytes, pixels, client_options, damage_time = pending bytecount = end_bytes-start_bytes - #it is possible + #it is possible though unlikely #that we get the ack before we've had a chance to call #damage_packet_sent, so we must validate the data: if bytecount>0 and end_send_at>0: