From 9d428b4315fb7ca7ff79d9b046e77e02939bee45 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 16 Oct 2018 15:16:07 +0200 Subject: PAPI: Add timeout support for socket transport Change-Id: I0402989e0ac738cab2f918e6e3d73c571457c08e Signed-off-by: Ole Troan --- src/vpp-api/python/vpp_papi/vpp_transport_socket.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py index 1822deb6d07..5fac11f3f29 100644 --- a/src/vpp-api/python/vpp_papi/vpp_transport_socket.py +++ b/src/vpp-api/python/vpp_papi/vpp_transport_socket.py @@ -6,6 +6,7 @@ import struct import threading import select import multiprocessing +import queue import logging @@ -67,11 +68,10 @@ class VppTransport: try: self.socket.connect(self.server_address) except socket.error as msg: - logging.error(msg) + logging.error("{} on socket {}".format(msg, self.server_address)) raise self.connected = True - # Initialise sockclnt_create sockclnt_create = self.parent.messages['sockclnt_create'] sockclnt_create_reply = self.parent.messages['sockclnt_create_reply'] @@ -173,4 +173,7 @@ class VppTransport: def read(self): if not self.connected: raise IOError(1, 'Not connected') - return self.q.get() + try: + return self.q.get(True, self.read_timeout) + except queue.Empty: + return None -- cgit 1.2.3-korg