17004: Fix lingering resource error
[arvados.git] / sdk / python / arvados / commands / get.py
index a377c149df15cc6e09ae6c2fdd56c97b5639cf40..bb421def618cddd36ba7d2241e2b1e81b58581ac 100755 (executable)
@@ -17,7 +17,6 @@ import arvados.util as util
 
 from arvados._version import __version__
 
-api_client = None
 logger = logging.getLogger('arvados.arv-get')
 
 parser = argparse.ArgumentParser(
@@ -98,11 +97,11 @@ When getting a collection manifest, strip its access tokens before writing
 it.
 """)
 
-parser.add_argument('--threads', type=int, metavar='N', default=2,
+parser.add_argument('--threads', type=int, metavar='N', default=4,
                     help="""
 Set the number of download threads to be used. Take into account that
 using lots of threads will increase the RAM requirements. Default is
-to use 2 threads.
+to use 4 threads.
 On high latency installations, using a greater number will improve
 overall throughput.
 """)
@@ -146,8 +145,6 @@ def parse_arguments(arguments, stdout, stderr):
     return args
 
 def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
-    global api_client
-
     if stdout is sys.stdout and hasattr(stdout, 'buffer'):
         # in Python 3, write to stdout as binary
         stdout = stdout.buffer
@@ -158,8 +155,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
     request_id = arvados.util.new_request_id()
     logger.info('X-Request-Id: '+request_id)
 
-    if api_client is None:
-        api_client = arvados.api('v1', request_id=request_id)
+    api_client = arvados.api('v1', request_id=request_id)
 
     r = re.search(r'^(.*?)(/.*)?$', args.locator)
     col_loc = r.group(1)
@@ -290,7 +286,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
                                        if todo_bytes==0
                                        else 100.0*out_bytes/todo_bytes)))
                     elif args.batch_progress:
-                        stderr.write('%s %d read %d total\n' %
+                        stderr.write('%s %d read %d total %d\n' %
                                      (sys.argv[0], os.getpid(),
                                       out_bytes, todo_bytes))
             if digestor: