I am currently learning multithreading and learned about concurrent.futures and the threading pool executor, i tried to implement an example but for some reason it was not printing the multiple print orders. where did i go wrong?
import requests
import random
import string
import concurrent.futures
result = open(r"workingGhosts.txt","w")
length = 5
url ="https://ghostbin.co/paste/"
def get_random_string(length):
letters = string.ascii_lowercase
result_str = ''.join(random.choice(letters) for i in range(length))
return result_str
times = int(input("how many times do you want to check?"))
list_urls=[]
counter = 0
for x in range(times):
stringA = url + get_random_string(length)
list_urls.append(stringA)
def lol(finalUrl):
r = requests.get(finalUrl)
counter= counter +1
print("printing")
if r.status_code != 404:
result.write(finalUrl)
with concurrent.futures.ThreadPoolExecutor() as executor:
executor.map(lol,list_urls)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…