diff --git a/swh/loader/core/loader.py b/swh/loader/core/loader.py --- a/swh/loader/core/loader.py +++ b/swh/loader/core/loader.py @@ -362,8 +362,6 @@ total_time_store_data = 0.0 try: - # Initially not a success, will be True when actually one - success = False with self.statsd_timed("prepare"): self.prepare() @@ -396,7 +394,8 @@ "post_load", tags={"success": success, "status": status} ): self.post_load() - except Exception as e: + except BaseException as e: + success = False if isinstance(e, NotFound): status = "not_found" task_status = "uneventful" @@ -416,7 +415,8 @@ }, }, ) - sentry_sdk.capture_exception() + if not isinstance(e, (SystemExit, KeyboardInterrupt)): + sentry_sdk.capture_exception() visit_status = OriginVisitStatus( origin=self.origin.url, visit=self.visit.visit, @@ -430,6 +430,10 @@ "post_load", tags={"success": success, "status": status} ): self.post_load(success=success) + if not isinstance(e, Exception): + # e derives from BaseException but not Exception; this is most likely + # SystemExit or KeyboardInterrupt, so we should re-raise it. + raise return {"status": task_status} finally: with self.statsd_timed(