summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2017-01-26 17:26:00 +0200
committerimarom <imarom@cisco.com>2017-01-26 17:34:28 +0200
commitacf815dbf67d7a3be8fefd84eea1d25465f71136 (patch)
tree6d6b68dd250cdc910c6aa51858532b1844dae868 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
parent3689edf311778c8cb921db61f293db6cd43a9b14 (diff)
code review - few cleanups
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
index db216532..405f76be 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py
@@ -10,6 +10,7 @@ import struct
from .trex_stl_types import *
from .utils.common import random_id_gen
from .utils.zipmsg import ZippedMsg
+from threading import Lock
class bcolors:
BLUE = '\033[94m'
@@ -72,6 +73,8 @@ class JsonRpcClient(object):
self.id_gen = random_id_gen()
self.zipper = ZippedMsg()
+ self.lock = Lock()
+
def get_connection_details (self):
rc = {}
rc['server'] = self.server
@@ -137,6 +140,12 @@ class JsonRpcClient(object):
def send_msg (self, msg, retry = 0):
+ # REQ/RESP pattern in ZMQ requires no interrupts during the send
+ with self.lock:
+ return self.__send_msg(msg, retry)
+
+
+ def __send_msg (self, msg, retry = 0):
# print before
if self.logger.check_verbose(self.logger.VERBOSE_HIGH):
self.verbose_msg("Sending Request To Server:\n\n" + self.pretty_json(msg) + "\n")