3 ms·
This space is in rough shape for python. Python ships with urllib, which is fairly neglected. People tend to use requests, which is better, but still doesn't
by tyingq 4y ago
This space is in rough shape for python. Python ships with urllib, which is fairly neglected. People tend to use requests, which is better, but still doesn't support normal keep-alives, so it's a new connection per request.
Also, urllib3 has a dependency on the shipped urllib, and requests depends on urllib3.
Edit: I was correct about urllib not doing keep-alive, but incorrect about urllib3 and requests...those support it.
- SethMLarson 4y agoWhere are you seeing this information? urllib, urllib3, and requests all support connection pooling, keep-alives, and re-use and have for a very long time. Maybe I'm not understanding part of your message?
- tyingq 4y agoFor urllib: "urllib.request module uses HTTP/1.1 and includes a "Connection:close" header in its HTTP requests"[1] [1] https://github.com/python/cpython/blob/3.10/Lib/urllib/request.py#L147 https://github.com/python/cpython/blob/3.10/Lib/urllib/reque... You seem to be correct about urllib3 and requests, I was wrong there...though they do have the dependency on urllib.
- unmole 4y ago> People tend to use requests, which is better, but still doesn't support normal keep-alives, so it's a new connection per request. What on earth is normal keep-alives in this context? And you can most certainly reuse connections with Session objects: https://requests.readthedocs.io/en/latest/user/advanced/ https://requests.readthedocs.io/en/latest/user/advanced/
- tyingq 4y agoI had remembered incorrectly. Urllib (the only one of the three that ships with python) is hobbled this way, it sends Connection: Close with every request. Urllib3 and requests don't have that issue.