[diffoscope] 04/04: Use keepalive in trydiffoscope client to avoid new HTTP requests.
Chris Lamb
chris at chris-lamb.co.uk
Sat Aug 13 23:32:56 CEST 2016
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit cd7945720fd9f5630e2f031c88ca77bbde8acbbd
Author: Chris Lamb <lamby at debian.org>
Date: Sat Aug 13 22:32:48 2016 +0100
Use keepalive in trydiffoscope client to avoid new HTTP requests.
---
bin/trydiffoscope | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bin/trydiffoscope b/bin/trydiffoscope
index e790067..0fe6e93 100755
--- a/bin/trydiffoscope
+++ b/bin/trydiffoscope
@@ -28,9 +28,10 @@ import webbrowser
class TryDiffoscope(object):
def __init__(self, args):
self.args = args
+ self.session = requests.Session()
def main(self):
- response = requests.post(self.args.endpoint, files={
+ response = self.session.post(self.args.endpoint, files={
'file_a': open(self.args.file[0], 'rb'),
'file_b': open(self.args.file[1], 'rb'),
})
@@ -39,7 +40,7 @@ class TryDiffoscope(object):
poll_uri = response.json()['result']['uri']
while True:
- response = requests.get(poll_uri)
+ response = self.session.get(poll_uri)
response.raise_for_status()
comparison = response.json()['result']
@@ -71,14 +72,14 @@ class TryDiffoscope(object):
to_save = {x for x in ('html', 'text') if getattr(self.args, x)}
for x in to_save:
- response = requests.get(comparison['formats'][x])
+ response = self.session.get(comparison['formats'][x])
response.raise_for_status()
with open(getattr(self.args, x), 'w') as f:
print(response.text, file=f)
if not to_save:
- response = requests.get(comparison['formats']['text'])
+ response = self.session.get(comparison['formats']['text'])
response.raise_for_status()
print(response.content.decode('utf-8'))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list