I have some tests that run in locust and as part of it, I create a unique ID and add it to an array. I would then like to run through those ID's at the end and check if they made it into the DB via a web call. It works perfectly fine but it is quite slow to run through each individually... so I believe I need to use multiprocessing (or maybe some other method?) to speed up the check, but so far I have not managed to get it to work.
Here is an example of code that I have written (obfuscated by sausages because... why not :) )
In this example the array only has 3 items in it, but if you can imagine that it has hundreds, what is the best way to make this multiprocessing please?
import requests
all_sausages = ["cumberland", "lego", "bratwurst"]
global yes
global no
yes = 0
no = 0
for sausage in all_sausages:
response = requests.get("http://www.isitasausage.com/" + sausage)
if response.text.__contains__("Yes, this is a sausage"):
yes += 1
else:
no =+ 1
print("Number of sausages in the array = " + str(yes))
print("Number of items in the array that are not sausages = " + str(no))