This problem occurs on Windows 10 (I know this, because it's not present on Mac OS).
Whenever you do a simple request to one of your endpoints like the following, it's extremely slow on Windows, whereas it's nearly instant on Mac OS.
import requests
requests.get('/user/get/' + str(current_user.id))
It takes about 3 seconds on Windows, while on Mac OS, it's nearly instantaneous.
By using some simple logging, I found that urllib3 (which is the underlying library for requests) takes a long time when making a new http connection. This is currently the pain point, and I don't have the knowledge to understand how to fix this.
DEBUG:urllib3.connectionpool:Starting new HTTP connection (1): localhost:5004
Failed fix 1:
I tried the following from this answer, but it does not work.
import requests
session = requests.Session()
session.trust_env = False
r = session.get('/user/get/' + str(current_user.id))
I also tried the following from the same answer, and it does not work.
os.environ['NO_PROXY'] = 'localhost'
Failed fix 2:
I tried a second supposed fix, and it did not work either.
import requests
proxies = {
"http": None,
"https": None,
}
r = requests.get('/user/get/' + str(current_user.id), proxies=proxies)
Now..
This leaves me with no answer and no available fix. Does someone know why this is an issue?