aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2018-10-16 15:16:07 +0200
committerOle Troan <ot@cisco.com>2018-10-16 15:16:07 +0200
commit9d428b4315fb7ca7ff79d9b046e77e02939bee45 (patch)
treea17be7d9d55f6090b892df7d1a1c155ce01fc4ef /src
parent710071bf0ed7a0926581d1f738a142b72e795d2b (diff)
PAPI: Add timeout support for socket transport
Change-Id: I0402989e0ac738cab2f918e6e3d73c571457c08e Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_transport_socket.py9
1 files changed, 6 insertions, 3 deletions
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