change poll test
@@ -13,17 +13,18 @@ import sys
from joblib import Parallel, delayed
num_concurrent_requests = int(sys.argv[1])
-recurrent_burst = len(sys.argv) > 2 and sys.argv[2] == '--repeat'
-wait_time_between_burst = 1 # in seconds
+wait_time_between_requests = 1 # in seconds
task_group_id = 'model_evaluator_1499629716'
db_last_message_id = 1000
json_api_endpoint_url = 'https://5lu5k95kwf.execute-api.us-east-1.amazonaws.com/prod/json'
-
-global get_request
-def get_request(request_id):
- print("Testing request: "+str(request_id))
+global test_thread
+def test_thread(thread_id):
+ print("Thread "+str(thread_id)+" is on.")
+ count = 0
+ while True:
+ count += 1
params = {
'method_name': 'get_new_messages',
'task_group_id': task_group_id,
@@ -32,16 +33,10 @@ def get_request(request_id):
response = requests.get(json_api_endpoint_url, params=params, allow_redirects=False)
try:
ret = json.loads(response.json())
- print('Success: '+str(ret))
+ print("Thread "+str(thread_id)+": Count: "+str(count)+" Success: "+str(ret))
+ time.sleep(wait_time_between_requests)
except Exception as e:
print(response.content)
raise e
-while True:
- results = Parallel(n_jobs=num_concurrent_requests, backend='threading')(delayed(get_request)(request_id) for request_id in range(num_concurrent_requests))
- print("One run completed")
- if recurrent_burst:
- time.sleep(wait_time_between_burst)
- else:
- break
-
+results = Parallel(n_jobs=num_concurrent_requests, backend='threading')(delayed(test_thread)(thread_id) for thread_id in range(num_concurrent_requests))
