Skip to content

Commit

Permalink
feat(aws sqs plugin): adds exception handling for ResourceClosedError…
Browse files Browse the repository at this point in the history
… errors
  • Loading branch information
mvilanova committed Dec 11, 2024
1 parent e55f9a1 commit d808515
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/dispatch/plugins/dispatch_aws/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import boto3
from psycopg2.errors import UniqueViolation
from pydantic import ValidationError
from sqlalchemy.exc import IntegrityError
from sqlalchemy.exc import IntegrityError, ResourceClosedError
from sqlalchemy.orm import Session

from dispatch.metrics import provider as metrics_provider
Expand Down Expand Up @@ -124,9 +124,15 @@ def consume(self, db_session: Session, project: Project) -> None:
f"Encountered an integrity error when trying to create a signal instance: {e}"
)
continue
except ResourceClosedError as e:
log.warning(
f"Encountered an error when trying to create a signal instance. The plugin will retry again as the message hasn't been deleted from the SQS queue. Signal name/variant: {signal_instance_in.raw['name'] if signal_instance_in.raw and signal_instance_in.raw['name'] else signal_instance_in.raw['variant']}. Error: {e}"
)
db_session.rollback()
continue
except Exception as e:
log.exception(
f"Unable to create signal instance. Signal name/variant: {signal_instance_in.raw['name'] if signal_instance_in.raw and signal_instance_in.raw['name'] else signal_instance_in.raw['variant']}. Error: {e}"
f"Encountered an error when trying to create a signal instance. Signal name/variant: {signal_instance_in.raw['name'] if signal_instance_in.raw and signal_instance_in.raw['name'] else signal_instance_in.raw['variant']}. Error: {e}"
)
db_session.rollback()
continue
Expand Down

0 comments on commit d808515

Please sign in to comment.