##// END OF EJS Templates
lfs: ensure that the return of urlopener.open() is closed...
Matt Harbison -
r40701:fb379b78 default
parent child Browse files
Show More
@@ -7,6 +7,7 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 import contextlib
10 11 import errno
11 12 import hashlib
12 13 import json
@@ -297,7 +298,7 b' class _gitlfsremote(object):'
297 298 batchreq.add_header('Accept', 'application/vnd.git-lfs+json')
298 299 batchreq.add_header('Content-Type', 'application/vnd.git-lfs+json')
299 300 try:
300 rsp = self.urlopener.open(batchreq)
301 with contextlib.closing(self.urlopener.open(batchreq)) as rsp:
301 302 rawjson = rsp.read()
302 303 except util.urlerr.httperror as ex:
303 304 hints = {
@@ -419,16 +420,18 b' class _gitlfsremote(object):'
419 420
420 421 response = b''
421 422 try:
422 req = self.urlopener.open(request)
423
423 with contextlib.closing(self.urlopener.open(request)) as req:
424 ui = self.ui # Shorten debug lines
424 425 if self.ui.debugflag:
425 self.ui.debug('Status: %d\n' % req.status)
426 # lfs-test-server and hg serve return headers in different order
427 self.ui.debug('%s\n'
426 ui.debug('Status: %d\n' % req.status)
427 # lfs-test-server and hg serve return headers in different
428 # order
429 ui.debug('%s\n'
428 430 % '\n'.join(sorted(str(req.info()).splitlines())))
429 431
430 432 if action == 'download':
431 # If downloading blobs, store downloaded data to local blobstore
433 # If downloading blobs, store downloaded data to local
434 # blobstore
432 435 localstore.download(oid, req)
433 436 else:
434 437 while True:
@@ -437,7 +440,7 b' class _gitlfsremote(object):'
437 440 break
438 441 response += data
439 442 if response:
440 self.ui.debug('lfs %s response: %s' % (action, response))
443 ui.debug('lfs %s response: %s' % (action, response))
441 444 except util.urlerr.httperror as ex:
442 445 if self.ui.debugflag:
443 446 self.ui.debug('%s: %s\n' % (oid, ex.read()))
General Comments 0
You need to be logged in to leave comments. Login now