Here is my code:
import os
import requests
from bs4 import BeautifulSoup
import time, random
from time import sleep
from concurrent.futures import ProcessPoolExecutor, as_completed
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import Future
import concurrent.futures
from threading import Thread
def task():
start_time = time.time()
with open("url.txt") as f:
for line in f:
line2 = line.rstrip("\r\n")
print(line2 + " Hello")
sleep(1)
#rechi = requests.get("http://"+line2, verify = False, timeout = 0.5)
#con = BeautifulSoup(rechi.content, "html.parser")
#title = con.title
#print(title)
print("My program took", time.time() - start_time, "to run")
def main():
executor = ThreadPoolExecutor(20)
future = executor.submit(task)
print(future.result())
main()
The time it takes to execute the program with threading is the same as without threading... Can somebody tell me what am i doing wrong please?