diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2017-02-20 16:01:44 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2017-02-20 16:01:44 +0300 |
commit | e39d0c8f8a309ad9565aff2fecf9e40fe68c0fde (patch) | |
tree | dd4dca80f1d228fe3eb7a985d819fa2baa13b20c /scripts | |
parent | c316b64d34300685e4a3b182d60f62973591b4f9 (diff) |
batching in client
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/client.py | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/scripts/client.py b/scripts/client.py index 0ffbd7a3..1ee43327 100755 --- a/scripts/client.py +++ b/scripts/client.py @@ -5,17 +5,26 @@ import time import sys filePath = sys.argv[1] -print filePath +batchSize = int(sys.argv[2]) +#print filePath with open(filePath) as f: + batchCount = 0 + batch = "" for line in f: #print line - line = line[:-1] - #print line - ws = create_connection("ws://localhost:8080/translate") - ws.send(line) - result=ws.recv() - print(result) - ws.close() - #time.sleep(5) + batchCount = batchCount + 1 + batch = batch + line + if batchCount == batchSize: + ws = create_connection("ws://localhost:8080/translate") + + batch = batch[:-1] + ws.send(batch) + result=ws.recv() + print(result) + ws.close() + #time.sleep(5) + + batchCount = 0 + batch = "" |