diff --git a/swh/vault/cookers/base.py b/swh/vault/cookers/base.py --- a/swh/vault/cookers/base.py +++ b/swh/vault/cookers/base.py @@ -6,6 +6,7 @@ import abc import io import logging +import psycopg2.extensions from swh.core import config from swh.model import hashutil @@ -111,7 +112,11 @@ self.fileobj = BytesIOBundleSizeLimit(size_limit=self.max_bundle_size) try: - self.prepare_bundle() + try: + self.prepare_bundle() + except psycopg2.extensions.QueryCanceledError as Exception: + raise PolicyError( + "Timeout reached when preparing the requested bundle") bundle = self.fileobj.getvalue() # TODO: use proper content streaming instead of put_bundle() self.backend.put_bundle(self.CACHE_TYPE_KEY, self.obj_id, bundle)