diff --git a/pychromecast/socket_client.py b/pychromecast/socket_client.py index 2e2e2bd98..3bfd3af9b 100644 --- a/pychromecast/socket_client.py +++ b/pychromecast/socket_client.py @@ -590,7 +590,7 @@ def send_message(self, destination_id, namespace, data, } self.socket.sendall(be_size + msg.SerializeToString()) except socket.error: - del self._request_callbacks[request_id] + self._request_callbacks.pop(request_id, None) self._force_recon = True self.logger.info('Error writing to socket.') else: