Merge branch '11423-cwl-collection-dir-ref' closes #11423
[arvados.git] / sdk / python / arvados / commands / put.py
index 5598e54ef2ba1068d314dcee43f479cadd3407c1..32d5fef6a8588e1f2785517435949082dd5b3534 100644 (file)
@@ -23,6 +23,8 @@ import sys
 import tempfile
 import threading
 import time
+import traceback
+
 from apiclient import errors as apiclient_errors
 from arvados._version import __version__
 
@@ -448,9 +450,14 @@ class ArvPutUploadJob(object):
             # Actual file upload
             self._upload_started = True # Used by the update thread to start checkpointing
             self._upload_files()
-        except KeyboardInterrupt:
-            self.logger.warning("User interrupt request, cleaning up before exiting.")
+        except (SystemExit, Exception) as e:
             self._checkpoint_before_quit = False
+            # Log stack trace only when Ctrl-C isn't pressed (SIGINT)
+            # Note: We're expecting SystemExit instead of KeyboardInterrupt because
+            #   we have a custom signal handler in place that raises SystemExit with
+            #   the catched signal's code.
+            if not isinstance(e, SystemExit) or e.code != -2:
+                self.logger.warning("Abnormal termination:\n{}".format(traceback.format_exc(e)))
             raise
         finally:
             if not self.dry_run: