Skip to content

Commit 217006b

Browse files
committed
Cache the user agent
This does not need to be computed multiple times in the same process.
1 parent a33caa2 commit 217006b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/pip/_internal/network/session.py

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import email.utils
6+
import functools
67
import io
78
import ipaddress
89
import json
@@ -106,6 +107,7 @@ def looks_like_ci() -> bool:
106107
return any(name in os.environ for name in CI_ENVIRONMENT_VARIABLES)
107108

108109

110+
@functools.lru_cache(maxsize=1)
109111
def user_agent() -> str:
110112
"""
111113
Return a string representing the user agent.

0 commit comments

Comments
 (0)