Increase timeout in upload thread canceling
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 11 Apr 2013 14:50:19 +0000 (17:50 +0300)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Thu, 11 Apr 2013 14:50:19 +0000 (17:50 +0300)
kamaki/cli/commands/pithos_cli.py

index cb1b352..4013dd4 100644 (file)
@@ -1313,15 +1313,20 @@ class store_download(_store_container_command):
                     if_unmodified_since=self['if_unmodified_since'])
         except KeyboardInterrupt:
             from threading import activeCount, enumerate as activethreads
+            timeout = 0.5
             while activeCount() > 1:
-                stdout.write('\nTry stop %s threads: ' % (activeCount() - 1))
+                stdout.write('\nCancel %s threads: ' % (activeCount() - 1))
+                stdout.flush()
                 for thread in activethreads():
-                    stdout.flush()
                     try:
-                        thread.join(0.5)
-                        stdout.write('*')
+                        thread.join(timeout)
+                        stdout.write('.' if thread.isAlive() else '*')
                     except RuntimeError:
                         continue
+                    finally:
+                        stdout.flush()
+                        timeout += 0.1
+
             print('\nDownload canceled by user')
             if local_path is not None:
                 print('to resume, re-run with --resume')