STL API: fix split batch to chunks - one packet not being sent 22/4322/1
authorYaroslav Brustinov <[email protected]>
Sun, 11 Dec 2016 08:30:22 +0000 (10:30 +0200)
committerYaroslav Brustinov <[email protected]>
Sun, 11 Dec 2016 08:30:22 +0000 (10:30 +0200)
Change-Id: Id2e96f2fe6a6c1bb0438198675a61f3c73d53072
Signed-off-by: Yaroslav Brustinov <[email protected]>
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_jsonrpc_client.py

index fbad9f7..51e93f5 100644 (file)
@@ -41,10 +41,9 @@ class BatchMessage(object):
             size = 0
             new_batch = []
             for msg in self.batch_list:
-                if size < chunk_size:
-                    size += len(json.dumps(msg))
-                    new_batch.append(msg)
-                else:
+                size += len(json.dumps(msg))
+                new_batch.append(msg)
+                if size > chunk_size:
                     batch_json = json.dumps(new_batch)
                     response = self.rpc_client.send_msg(batch_json)
                     if not response: