Skip to content

Commit fd0c66a

Browse files
committed
base: Use requests.Session, gives us HTTP KeepAlive
Unfortunately bugzilla.redhat.com doesn't support it: https://bugzilla.redhat.com/show_bug.cgi?id=1273544 But bugzilla.mozilla.org does, and maybe others
1 parent 90317e5 commit fd0c66a

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

bugzilla/base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ def __init__(self, url, cookiejar=None,
204204
}
205205
}
206206

207+
# Using an explicit Session, rather than requests.get, will use
208+
# HTTP KeepAlive if the server supports it.
209+
self.session = requests.Session()
210+
207211
def parse_response(self, response):
208212
""" Parse XMLRPC response """
209213
parser, unmarshaller = self.getparser()
@@ -218,7 +222,7 @@ def _request_helper(self, url, request_body):
218222
"""
219223
response = None
220224
try:
221-
response = requests.post(
225+
response = self.session.post(
222226
url, data=request_body, **self.request_defaults)
223227

224228
# We expect utf-8 from the server
@@ -1536,7 +1540,8 @@ def get_filename(headers):
15361540
defaults["headers"] = defaults["headers"].copy()
15371541
del(defaults["headers"]["Content-Type"])
15381542

1539-
response = requests.get(att_uri, stream=True, **defaults)
1543+
response = self._transport.session.get(
1544+
att_uri, stream=True, **defaults)
15401545

15411546
ret = BytesIO()
15421547
for chunk in response.iter_content(chunk_size=1024):

0 commit comments

Comments
 (0)