Код:
import requests
import pandas as pd
import concurrent.futures
with open("load_test_data.json") as f:
request_data = json.load(f)
response_details = {}
response_details['content'] = []
response_details['status_code'] = []
response_details['time'] = []
counter = 0
def hit_the_url(request_content):
url = "http://xxxxxx"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = request_content)
counter += 1
print(f"{counter} number of requests performed")
response_details['content'].append(response.content)
print(response.status_code)
response_details['status_code'].append(response.status_code)
print(response.elapsed.total_seconds())
response_details['time'].append(response.elapsed.total_seconds() * 1000)
return 'Success'
with concurrent.futures.ProcessPoolExecutor() as executor:
results = [executor.submit(hit_the_url, i) for i in request_data ]
for f in concurrent.futures.as_completed(results):
print(f.result())
df = pd.DataFrame(response_details)
df.to_csv("response_details.csv")
Какую ошибку я здесь делаю? Код ничего не печатает. Не прекращается и это. Када в зависшем состоянии.
PS, попробуйте многопроцессорный модуль впервые. Пожалуйста помоги. БЛАГОДАРЯ