I updated from Ubuntu 20.04 to 22.04 and now all my python scripts with HTTPS requests are much slower than before (0.7 sec vs. ~2 sec).
import requests
import threading
import time
def req():
r = requests.get('https://www.google.com/')
for i in range(10):
thread_amount = 50
threads = []
s = time.time()
for i in range(thread_amount):
threads.append(threading.Thread(target = req))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
e = time.time()
total_time = e - s
print(f"total time: {total_time} s")
time.sleep(1)
This is caused by openssl 3.0.2 and any other openssl 3.xx version. That's why I tried to install openssl 1.1.1s, which worked fine, but afterwards you have to re-compile python to make it use openssl 1.1.1s. Unfortunately this breaks everything for me. I need a solution which works with openssl 3.
try disabling the verification of the SSL certificate (this should increase loading times) (also this works with the latest version of OpenSSL
def req():
r = requests.get('https://www.google.com/', verify=False)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.