fixed stuff
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pünkösd Marcell 2021-07-22 18:35:04 +02:00
parent d9e05538fe
commit c430232df0

View File

@ -66,25 +66,43 @@ def print_progress_meme(char: str):
def allout_sender_worker(input_queue, sent_queue, target_url: str, file_contents: bytes, request_timeout: float): def allout_sender_worker(input_queue, sent_queue, target_url: str, file_contents: bytes, request_timeout: float):
content_len = len(file_contents)
session = requests.Session()
try: try:
prepared_curl = pycurl.Curl()
prepared_curl.setopt(pycurl.URL, target_url)
prepared_curl.setopt(pycurl.SSL_VERIFYPEER, 0)
prepared_curl.setopt(pycurl.SSL_VERIFYHOST, 0)
prepared_curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_2_0)
prepared_curl.setopt(pycurl.WRITEFUNCTION, lambda data: None)
while True: while True:
try: try:
job = input_queue.get_nowait() job = input_queue.get_nowait()
except queue.Empty: except queue.Empty:
return return
job.upload_started = time.time() files = {
prepared_curl.perform() "file": (
job.upload_finished = time.time() f"birbbenchmark2_testfile_{job.id}.wav",
file_contents,
'audio/wave',
{'Content-length': content_len}
),
"description": (
None,
json.dumps({'date': datetime.now().isoformat(), 'device_id': str(job.id)}),
"application/json"
)
}
try:
job.upload_started = time.time()
r = session.post(target_url, files=files, timeout=request_timeout)
job.upload_finished = time.time()
status_code = r.status_code
except requests.exceptions.Timeout:
print_progress_meme('?')
continue
except requests.exceptions.ConnectionError:
print_progress_meme('!')
continue
status_code = prepared_curl.getinfo(pycurl.HTTP_CODE)
if status_code == 200: if status_code == 200:
print_progress_meme('.') print_progress_meme('.')
else: else:
@ -100,27 +118,46 @@ def allout_sender_worker(input_queue, sent_queue, target_url: str, file_contents
def timeouting_sender_worker(input_queue, sent_queue, target_url: str, file_contents: bytes, request_timeout: float, def timeouting_sender_worker(input_queue, sent_queue, target_url: str, file_contents: bytes, request_timeout: float,
timeout: float): timeout: float):
content_len = len(file_contents)
session = requests.Session()
start_time = time.time()
count = 0
try: try:
prepared_curl = pycurl.Curl()
prepared_curl.setopt(pycurl.URL, target_url)
prepared_curl.setopt(pycurl.SSL_VERIFYPEER, 0)
prepared_curl.setopt(pycurl.SSL_VERIFYHOST, 0)
prepared_curl.setopt(pycurl.HTTP_VERSION, pycurl.CURL_HTTP_VERSION_2_0)
prepared_curl.setopt(pycurl.WRITEFUNCTION, lambda data: None)
start_time = time.time()
count = 0
while True: while True:
try: try:
job = input_queue.get_nowait() job = input_queue.get_nowait()
except queue.Empty: except queue.Empty:
return return
job.upload_started = time.time() files = {
prepared_curl.perform() "file": (
job.upload_finished = time.time() f"birbbenchmark2_testfile_{job.id}.wav",
file_contents,
'audio/wave',
{'Content-length': content_len}
),
"description": (
None,
json.dumps({'date': datetime.now().isoformat(), 'device_id': str(job.id)}),
"application/json"
)
}
status_code = prepared_curl.getinfo(pycurl.HTTP_CODE) # SUPER HIGH PRECISION MEASUREMENT COMPARTMENT DEPARTMENT ADMIRAL GENERAL ALADEEN
try:
job.upload_started = time.time()
r = session.post(target_url, files=files, timeout=request_timeout)
job.upload_finished = time.time()
except requests.exceptions.Timeout:
print_progress_meme('?')
continue
except requests.exceptions.ConnectionError:
print_progress_meme('!')
continue
status_code = r.status_code
if status_code == 200: if status_code == 200:
print_progress_meme('.') print_progress_meme('.')
else: else:
@ -139,6 +176,7 @@ def timeouting_sender_worker(input_queue, sent_queue, target_url: str, file_cont
except KeyboardInterrupt: except KeyboardInterrupt:
return return
def mqtt_on_connect(client, userdata, flags, rc): def mqtt_on_connect(client, userdata, flags, rc):
client.subscribe(f"command/#") client.subscribe(f"command/#")
@ -178,6 +216,7 @@ def infinite_job_generator(input_queue, target_ready_jobs: int):
if not threading.current_thread().active: if not threading.current_thread().active:
return return
def run_benchmark( def run_benchmark(
num_requests: int, num_requests: int,
num_workers: int, num_workers: int,